To create new lines, simply add a newline to the end of the line:
FileWriter writer = ... writer.write("The line\n");
In addition, the PrintWriter
class provides methods that automatically add newline characters for you ( edit: it also automatically uses the correct newline line for your OS):
PrintWriter writer = ... writer.println("The line");
source share