0
继承人我的代码:有文件I/O麻烦的Android
String path = "/data/data/edu.bfit.readwritedemo/files/test.txt";
FileInputStream fis;
File file = new File(this.getFilesDir().getAbsolutePath() + path);
try {
fis = new FileInputStream(file);
sBuffer = new StringBuffer();
BufferedReader dataIO = new BufferedReader(new InputStreamReader(fis));
while((strLine = dataIO.readLine()) != null)
sBuffer.append(strLine + "\n");
strLine.substring(0,4);
dataIO.close();
fis.close();
Toast.makeText(ActivityOne.this, "read successful!!", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
Toast.makeText(ActivityOne.this, "read failed!!", Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
文件保存无法打开。我觉得问题在于这条路,这是我困惑的地方。我为测试目的手动创建了test.txt,并将其存储在项目根目录中的一个目录中。我命名了这个目录文件,这是我想要指向的文件对象的路径。我是否全部错了?我的主要目标是能够读取Android系统上的系统文件并搜索子字符串。在此先感谢,我对墙上的文字表示歉意。
如果您计划与应用程序(即,不产生)它更容易使用'raw' [资源文件(http://developer.android.com/guide/topics打包文件/resources/providing-resources.html)。 – dmon 2013-04-18 04:24:32
我想最终要做的是读取Android存储在/ data/system/wpa_supplicant中的数据,以便我可以选出保存的wifi网络 – Cvsolidx17 2013-04-18 04:51:49
我相信该设备必须是根。 – dmon 2013-04-18 13:22:43