Java FileWriter only writing first line
-
12-11-2019 - |
题
I am working on a Java application that has a JTextArea for users to input text. It can be any amount of lines, however I am running into a problem with my FileWriter, where it's only saving the first line of any input. I've never used Swing or FileWriter before at all, so I may be getting this quite wrong, but here's my code:
FileWriter fw = null;
try {
fw = new FileWriter(lastSavedFile);
details.write(fw);
} catch (IOException exception) {
System.err.println("Error saving file");
exception.printStackTrace();
} finally {
if (fw != null) {
try {
fw.close();
} catch (IOException exception) {
System.err.println("Error closing writer");
exception.printStackTrace();
}
}
}
Thanks!
没有正确的解决方案
不隶属于 StackOverflow