How to get all the files which are stored with the help of FileOutputStream ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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.

8th Sep 2018, 5:53 AM
Master Gaurav
Master Gaurav - avatar
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.
11th Sep 2018, 4:27 AM
Gulshan Kumar Singh
Gulshan Kumar Singh - avatar