您的位置:首页 > 移动开发 > Android开发

android 读取sd卡文件的内容用TextView显示

2011-08-19 09:10 519 查看
//从文件读取文字,显示到当前的页面里

TextView tv1_lxy = (TextView)findViewById(R.id.text_lxy);

File f1 = new File(PATH + "orderdish/file/introduct.txt");

String str = null;

try {

InputStream is = new FileInputStream(f1);

InputStreamReader input = new InputStreamReader(is, "UTF-8");

BufferedReader reader = new BufferedReader(input);

while ((str = reader.readLine()) != null) {

tv1_lxy.append(str);

tv1_lxy.append("\n");

Log.d("餐厅介绍", str);

}

} catch (FileNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: