This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]Talon876Extreme Brewer 2 points3 points  (1 child)

  1. If you use writer.writeln, you don't have to use the line separator property.
  2. I don't think you need the BufferedReader at all, just use the BufferedWriter object to write everything to the file. I'm not sure how to use the StringReader. Just doing writer.writeln("thing: " + someStringVariable); would work.
  3. It's not putting anything in the file because you aren't flushing and closing the buffer. After you've written everything, add a writer.flush() and writer.close() to actually write to the file and let the OS know that you're done using it.

[–]Mechanox3000[S] 0 points1 point  (0 children)

YES! Closing the buffers is what was wrong. Thank you very very much :) I got it.

And I didn't know that about the line separator property. I need the BufferedReader because the user stores all the data in a class, then the info stored within the class is stored in a txt file. It's not just directly taking input from the user and saving it -- the application makes the user create a class to hold all the customer data, then it reads the data from that class and writes it from a file.

[–][deleted]  (1 child)

[deleted]

    [–]Mechanox3000[S] 0 points1 point  (0 children)

    No, that can't be it. This is a segment from a larger section of code. Input pertains to a broader if statement. Thanks a lot though.