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

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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: