How to read a local (res/raw) file line by line?

2020-02-14 16:46发布

I have a text file in my res/raw directory. I want to read the file line by line, but FileReader and BufferedReader fail, because of Android's security restriction. How else can I do it?

2条回答
Luminary・发光体
2楼-- · 2020-02-14 17:38

getResources().openRawResource() returns an InputStream that should be usable for line-by-line reading.

查看更多
Bombasti
3楼-- · 2020-02-14 17:38

A DataInputStream allows you to do a readLine (along with a host of other operations); see DataInputStream Reference.

查看更多
登录 后发表回答