Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Line Break in text file android

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();
like image 945
aftab Avatar asked Dec 01 '22 21:12

aftab


2 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();
like image 67
confucius Avatar answered Dec 10 '22 12:12

confucius


osw.append('\n'). Is that what you're looking for?

like image 43
Mxyk Avatar answered Dec 10 '22 13:12

Mxyk