I would like to add a little more to MadProgrammer's answer.
In the case of multi-line recording when executing the command
writer.write(string);
you may notice that newlines are omitted or omitted in the recorded file, even if they appear during debugging or if the same text is printed on the terminal using
System.out.println("\n");
Thus, the entire text appears as one large piece of text, which is undesirable in most cases. A newline character may be platform dependent, so itβs best to get that character from the properties of the java system using
String newline = System.getProperty("line.separator");
and then using a newline variable instead of "\ n". This will give the result the way you want.
Menezes Sousa Dec 04 '13 at 9:47 a.m. 2013-12-04 09:47
source share