Reputation: 1141
Hi All I am using this code to append text in a txt file.anyone can guide me how i can add line break for this case
fOut = new FileOutputStream(new File(myFilePath + BlueFreeConstants.logFileName), true);
osw = new OutputStreamWriter(fOut);
osw.append("<< " + values + " >>");
osw.flush();
osw.close();
fOut.close();
Upvotes: 4
Views: 13297
Reputation: 51
This is my code to create a multiline text file:
FileOutputStream fos=null;
OutputStreamWriter osw;
try {
fos = openFileOutput("login.txt",Context.MODE_PRIVATE);
fos.write(("Line One").getBytes());
osw = new OutputStreamWriter(fos);
osw.append("\r\n");
osw.append("Line Two");
osw.flush();
osw.close();
fos.flush();
fos.close();
} catch (Exception e) {}
Upvotes: 1
Reputation: 13327
String separator = System.getProperty("line.separator");
fOut = new FileOutputStream(new File(myFilePath + BlueFreeConstants.logFileName), true);
osw = new OutputStreamWriter(fOut);
osw.append("<< " + values + " >>");
osw.append(separator); // this will add new line ;
osw.flush();
osw.close();
fOut.close();
Upvotes: 13