Reading a textfile using InputStream

前端 未结 3 1179
耶瑟儿~
耶瑟儿~ 2020-12-31 01:04

How can I read a text file like in android app:

\"1.something written
2.in this file
3.is to be read by
4.the InputStream
...\"

so I can be

3条回答
  •  被撕碎了的回忆
    2020-12-31 01:25

                    File fe=new File(abc.txt);
                    FileInputStream fis=new FileInputStream(fe);
                    byte data[]=new byte[fis.available()];
                    fis.read(data);
                    fis.close();
                    String str=new String(data);
                    System.out.println(str);
    

提交回复
热议问题