【发布时间】:2015-03-24 07:18:08
【问题描述】:
我有一个使用 ScrollView 和 TextView 的简单程序,它显示一个长文本文件,但它似乎删除了其中的换行符。例如,如果文本文件实际上有
Bunnies are mean.
But it's okay.
Because they're fluffy.
显示为
Bunnies are mean. But it's okay. Because they're fluffy.
这是我的代码的样子:
txt = (TextView)findViewById(R.id.txt);
stream = getResources().openRawResource(R.drawable.textBunny);
DataInputStream d = new DataInputStream(stream);
String line=null;
StringBuffer buffer=new StringBuffer();
try {
while((line=d.readLine())!=null){
buffer.append(line);
}
} catch (IOException e) {
e.printStackTrace();
}
txt.setText(buffer.toString());
帮忙,有人吗?提前致谢!
【问题讨论】:
标签: android eclipse stringbuffer datainputstream