Im making a simple network app and want to load the chat log on start up, this works fine but it formats the text as one line
Writing to file
CharSequence cs = tv.getText ();
final String str = cs + "\r\n" + s;
//Write to text file
try {
FileOutputStream fos = openFileOutput("Chat Log", Context.MODE_APPEND);
fos.write(s.getBytes());
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
catch (IOException e1)
{
e1.printStackTrace();
}
//close the socket
socket.close();
Reading Text
final TextView tv = (TextView)findViewById(R.id.textView1);
try {
BufferedReader inputReader = new BufferedReader(new InputStreamReader(
openFileInput("Chat Log")));
String inputString;
StringBuffer stringBuffer = new StringBuffer();
while ((inputString = inputReader.readLine()) != null) {
stringBuffer.append(inputString + "\r\n");
tv.append(inputString);
}
} catch (IOException e) {
e.printStackTrace();
}
Current Result Screenshot