Welcome to the Ranch
I am afraid your code is difficult to read, because it is not indented. Please go back and click the edit button and add
code tags. Highligh from the beginning of each class to its end and push the code button.
Why are you using DataOutputStreams? Those are intended for binary files, and you have text files, for which BufferedReader, BufferedWriter, FileReader and FileWriter are much more appropriate. Look in the
Java Tutorials and keep going until you see the section about buffered streams. You will find an example of what I mean in there.
It is not at all a good idea to leave a reader or a writer open. You really out to close them, preferably in a
finally block. If you don’t close them, there is the risk of those files being locked and becoming unavailable to other applications. Tthere is also the risk that your writing is never terminated, and if the writing is never terminated, you might have all your text in the buffer still and nothing in the file
Look up
this method, and then look for
close(), which tells you that you don’t need to call the previous method!
Remember, always close readers and writers (except for System.out, System,in and System.err) when you have finished with them.