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

徘徊边缘 提交于 2019-11-28 09:43:19

问题


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?


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/3219150/how-to-read-a-local-res-raw-file-line-by-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!