我正在尝试读取 .txt 文件。但在文本视图中,文本未格式化。我,即使我已经给出了新行,文本视图中也没有新行。句子是连续的。可以格式化吗?代码是这样的
final StringBuffer buffer = new StringBuffer();
try{
DataInputStream dataIO= new DataInputStream(getResources().openRawResource(R.raw.chapter1));
String strLine= null;
while((strLine = dataIO.readLine())!=null){
buffer.append(strLine);
}
dataIO.close();
}catch(Exception e){
}
TextView tv=(TextView) findViewById(R.id.chapter);
tv.setText(buffer.toString());
}