Hi i've looked at all the other questions similar to this that I could find and haven't been able to fix my last problem, though the answers to other questions got me this far.
I'm trying to write an array to a file, and so far I can do that, but the writer just writes everything on the same line. For some reason it won't accept my new line command (\n) when viewed in notepad.
An example to try and explain:
Array contents: test, test2, test3, test4
Write to file
File contents: test test2 test3 test4
Whereas i want the file to be: test test2 test3 test4
Below is the segment of my code to write to the file.
public void save(String fileName) throws FileNotFoundException {
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(fileName));
for ( int i = 0; i < nbrMovies; i++)
{
writer.write(movies[i].getName() + " \n");
}
writer.close();
} catch(IOException ex) {
ex.printStackTrace();
}
}
The file doesn't accept the "\n" command and instead just puts a little box next to the last movie added.
Any and all help would be greatly appreciated.