Fliereader/Filewriter (Need Help!)
Ok so Im trying to make a program in Java that will act as an ATM. What I want it to be able to do is have someone enter a starting balance and then have the ability to withdraw money and deposit money into that account. The hard part is that I want the program to keep that account balance, so even after I close the program, the amount in the balance is still stored. Right now im just doing a little test try out FileWriter and FileReader in Java. So here is my code:
I keep getting this error "required : boolean found: int" and "required : int found: boolean" Im assuming it has to do with the line "while((str = br.readLine() !null))
Thanks! :)
I got rid of the != null, since from my understand, null is mostly used for string. I have used this program before for doing almost this same job, but instead of using an integer, I used a String. It worked like a charm, and it printed out the String correctly. This time however, I can get the integer to save to the "File.txt" but it wont reprint the value. After fixing it and recompiling it, I not get the error "Incomparable Types: int and String".
Re: Fliereader/Filewriter (Need Help!)
See the API for the classes and methods you are using.
BufferedReader (Java Platform SE 6)
Note the returned value from readLine is a String. Why is the variable str of type int? Easy fix is to change it to a String.
Re: Fliereader/Filewriter (Need Help!)
I have str set as a variable int because I was thinking that since the data that is stored on the "File.txt" that is going to be read is an int, that the variable str should be an integer. Ill see if changing the variable to a String will help. Thanks! :D
--- Update ---
Ok, it was a combination of the variable str, and a small little error in my brackets. Its working now! Thanks a million!