+ 3
How to get all the files which are stored with the help of FileOutputStream ?
i have an application in which i have stored data in text files on android device via FileOutputStream. FileOutputStream fout=openFileOutput("Addr.txt",MODE_PRIVATE); fout.write(c.getBytes()); now i want to show these files on a separate screen. i want to know how to fetch all these files which i have saved.
1 Answer
+ 1
hello, you can use fileinputstream to read those file.
FileInputStream fin=new FileInputStream("Addr.txt");Â
int i=0;Â
while((i=fin.read())!=-1){Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
System.out.print((char)i);Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
}Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
fin.close();
but don't forget to wrap this code in try catch block as it throws exceptions.