Reputation: 660
I have a simple program using ScrollView and TextView that displays a long text file, but it seems to delete the line breaks in it. Example, if the text file actually has
Bunnies are mean.
But it's okay.
Because they're fluffy.
it is displayed as
Bunnies are mean. But it's okay. Because they're fluffy.
This is what my code looks like:
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());
Help, anyone? Thanks in advance!
Upvotes: 0
Views: 125
Reputation: 48272
buffer.append(line).append(System.getProperty("line.separator"));
Upvotes: 1