I have the following code to print a string(from a ResultSet) to a text file:
PrintWriter writer = new PrintWriter(new FileOutputStream(file, false));
while(
You can use PrintWriter#println() method instead.
From API:
Terminates the current line by writing the line separator string. The line separator string is defined by the system property line.separator, and is not necessarily a single newline character ('\n').
Also this should work as well.
writer.write(RS.getString(1)+ System.getProperty("line.separator"));
You should use println to print a newline character after each line:
writer.println(RS.getString(1));
Use, in the statement. For example:
writer.print("1"+"<br/>");
writer.print("2"+"<br/>");