So I'm planning to make a level editor for a game and to do that I must be able to read and save files. Now I'm making a program that opens a textfile and shows the text in a JTextArea but the append() method doesn't work where it's supposed to. It seems it stops working after I opened a dialog with filechooser. So what's wrong?
Each time you call createContentPane(), a new JTextArea is created and the member variable "log" set to point to it. The original one is still on the screen, but "log" isn't referring to it anymore. You're then appending to another JTextArea that isn't visible!
I don't understand why you're calling this method repeatedly, when you've got a member variable to refer to everything else; just store the return value the very first time you call it into a member, and use that member everywhere else.
You didn't close the writer after you finished using it. Since writing to disk files happens in chunks of several K bytes at a time (because that's how the operating system deals with files), you're losing the last chunk. Which is probably the whole thing. Close the writer in a finally block like this:
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com