现在的位置: 首页 > 综合 > 正文

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

2013年12月11日 ⁄ 综合 ⁄ 共 578字 ⁄ 字号 评论关闭

//从文件读取文字,显示到当前的页面里
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();
}

【上篇】
【下篇】

抱歉!评论已关闭.