伙计们,我在 sdcard 中有一个文本文件,我需要阅读该文件。
下面是我读取文件的代码:
File f = new File(Environment.getExternalStorageDirectory()+"/f1.txt");
fileIS = new FileInputStream(f);
BufferedReader buf = new BufferedReader(new InputStreamReader(fileIS));
String readString = new String();
//just reading each line and pass it on the debugger
while((readString = buf.readLine())!= null){
textdata.setText(readString);
Log.d("line: ", readString);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e){
e.printStackTrace();
}
但我需要动态地从 sdcard 读取文件。
在这里,我给了它f1.txt