For platform independent way use this:
w.write(System.getProperty("line.separator"));
Pregunta
My snippet code are as follow:
FileOutputStream fos = new FileOutputStream("newFile.txt");
OutputStreamWriter out = new OutputStreamWriter(fos, "UTF-8");
Writer w = out;
for(String str : arrayName)
{
w.write("sample");
//I wish to insert new line here
}
w.close();
Is there other way than to write a blank space manually? i.e. w.write("\n");
EDITED. Sorry for causing some misunderstanding regarding if I am looking for new line or blank space.
Solución
For platform independent way use this:
w.write(System.getProperty("line.separator"));
Otros consejos
w.write("\n");
Well apparently this answer was to short.
Read Java documentation about special characters For blank space (space character) just do:
w.write(" ");
try this
PrintWriter bw = new PrintWriter(new File("newFile.txt"), "UTF-8");
...
bw.println("sample");