android读入一个txt文件
2015-09-26 10:21
555 查看
BufferedReader br = null;
try {
String fileName = getIntent().getStringExtra(KEY_FILE_NAME);
br = new BufferedReader(new InputStreamReader(getAssets().open(fileName)));
String line;
StringBuffer sb = new StringBuffer();
while ((line = br.readLine()) != null) {
sb.append(line + "\n");
}
text = sb.toString();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
mJustifiedText.setText(text);
try {
String fileName = getIntent().getStringExtra(KEY_FILE_NAME);
br = new BufferedReader(new InputStreamReader(getAssets().open(fileName)));
String line;
StringBuffer sb = new StringBuffer();
while ((line = br.readLine()) != null) {
sb.append(line + "\n");
}
text = sb.toString();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
mJustifiedText.setText(text);
相关文章推荐
- Android环境搭建
- Android IM之基于Openfire+Smack的聊天服务器的搭建与测试
- Android系统的常用权限整理
- 分享:Android -- Properties使用
- Android开发笔记---Android控件
- Android入门——Service详解及应用(一)
- Android Studio 更换debug.keystore问题
- xml解析--Pull方式
- Android中SurfaceView和view画出触摸轨迹
- Android屏幕适配
- Android_完全退出
- Android 雷达扫描效果
- Android之单选控件RadioGroup,RadioButton使用
- Android应用开发系列(一):splash引导界面开发
- Android 四种基本布局LinearLayout、RelativeLayout、FrameLayout、TableLayout
- 【Android杂谈】AsyncTask的详细使用解析
- Android解决软键盘遮挡Button
- Android 之SharedPreference使用
- android 基础3
- Android —页面下拉刷新(ListView与SwipeRefreshLayout)