java - Having trouble with File I/O in Android -


heres code:

 string path = "/data/data/edu.bfit.readwritedemo/files/test.txt";     fileinputstream fis;     file file = new file(this.getfilesdir().getabsolutepath() + path);     try {             fis = new fileinputstream(file);             sbuffer = new stringbuffer();             bufferedreader dataio = new bufferedreader(new inputstreamreader(fis));             while((strline = dataio.readline()) != null)                     sbuffer.append(strline + "\n");             strline.substring(0,4);             dataio.close();             fis.close();             toast.maketext(activityone.this, "read successful!!", toast.length_short).show();     } catch (ioexception e) {         toast.maketext(activityone.this, "read failed!!", toast.length_short).show();         e.printstacktrace();     } 

the file keeps failing open. feel issue path , confused. manually created test.txt testing purposes , stored in directory in root directory of project. named directory files, , path point file object. going wrong? main goal able read in system file on android system , search substring. in advance, apologies wall o' text.

use this... goes downloads folder can change variable other system variables.

file path=environment.getexternalstoragepublicdirectory(environment.directory_downloads); file textfile = new file(path, "test.txt");

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -