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
  • 274,122
  • 60
  • 696
  • 724
Joe
  • 4,877
  • 5
  • 30
  • 51

0 Answers0