Add line break in android text file

Hi everyone, I use this code to add text to txt file.anyone can help me, how can I add a 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(); 
+4
source share
4 answers
 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(); 
+9
source

osw.append('\n') . Is this what you are looking for?

+2
source
 osw.append("<<"+values+">>\n"); 
+2
source

This is my code for creating a multi-line 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) {} 
+1
source

All Articles