通过FileOutputStream输出的文本文件

时间:2013-07-10 21:14:34

标签: android textview fileoutputstream

如何输出文本文件,以便我可以在LogCat中看到单独的文本行。该文件位于res / raw /目录中,我只需要有关如何执行此操作的基本帮助。我已经拥有了获取FileOutputStream提供的信息所需的代码,但我不确定如何让它首先读取它。

1 个答案:

答案 0 :(得分:0)

要从原始资源文件夹中读取文本文件,您可以使用以下代码段:

BufferedReader br = new BufferedReader(new InputStreamReader(getResources().openRawResource(YOUR_RESOURCE_ID)));
String line = null;
while ((line = br.readLine()) != null) {
    // Do whatever with the read line here
    // to write it to logcat e.g. use Log.i("TAG", line);
}
br.close();