0

I have the following code:

File aFile = new File("data.txt");

try {
   FileWriter aFileWriter = new FileWriter(aFile);
   aFileWriter.write("Hello.\n");
   aFileWriter.write("This is.\n");
   aFileWriter.write("A Test.\n");
}
catch (Exception anException){
   System.out.println("Error: " + anException);
}

This is supposed to write

Hello.
This is.
A Test.

but on to three different lines. As you can see I included \n as a line separator, but it does not seem to work.

Does anyone know how to get the line separator to work correctly please?

Sotirios Delimanolis
  • 263,859
  • 56
  • 671
  • 702
Joe
  • 4,691
  • 5
  • 29
  • 48

0 Answers0