Skip to content
Advertisement

Java: Bank simulation: Write to file, erased text/writing symbols

As a way to learn java, I attempted to write something simulating a bank(adding or removing numbers). I succeeded in creating a file(if one does not exist already), and then read from it, but when I attempt to write to it, it fails. I started with FileWriter, where it just erased the text in the document(balance.txt). I then tried BufferedWriter, and it wrote to the document, but it was just symbols instead of actual text/numbers. I’m aware that I’m a newbie when it comes to coding, but is there a solution to this? Thank you.

JavaScript

Advertisement

Answer

public FileWriter(String fileName, boolean append)

I think you should use append to edit your file.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement