【发布时间】:2014-02-05 20:51:20
【问题描述】:
我正在尝试从我的 sd 中读取文件 numbersmesa11,但我在最后的 while 子句中有一个错误,我不知道该怎么做,我将不胜感激!我真的卡住了
private void readVectorFromFile() {
InputStreamReader flujo=null;
BufferedReader lector=null;
try
{
File ruta = Environment.getExternalStorageDirectory();
File fichero = new File(ruta.getAbsolutePath()+"/BioCasinoStats", "numerosmesa11.txt");
flujo= new InputStreamReader(new FileInputStream(fichero));
lector= new BufferedReader(flujo);
String texto = lector.readLine();
while(texto!=null)
{
tbTexto.setText(texto);
texto=lector.readLine();
}
}
catch (Exception ex)
{
Log.e("ivan", "Error al leer fichero desde tarjeta SD");
}
finally
{
try {
if(lector!=null)
lector.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
【问题讨论】:
-
确保所有 catch 块都打印堆栈跟踪,从 logcat 获取,然后发布。
-
请发布您遇到的错误
-
I have an error in the final while clause- 什么错误? -
说tbtexto无法解析
-
it says tbtexto cannot be resolved。和读文件有什么关系?
标签: java android android-sdcard