Question

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!

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top