FIS = new FileInputStream (f);
P.load (FIS); System.out.println (toaccno+ p.getproperty ("name") +p.getproperty ("password") +money); Account TOACC = new Account (Toaccno,.getproperty ("name"),. GetProperty ("password"), money); if (Acc.getmoney () >= Money) { System.out.println ("Transfer succeeded! "); Acc.setmoney (Acc.getmoney ()-money); Toacc.setmoney (Toacc.getmoney () + money);
FOS = new FileOutputStream (f);
P.setproperty ("Accno", Toacc.getaccno ());p. SetProperty ("name", Toacc.getname ());p. SetProperty ("Password", Toacc.getpassword ());p. SetProperty ("Money", New Integer (Toacc.getmoney ()). ToString ()); try {p.store (FOS, null);} catch (IOException e) {e.printstacktrace ();} Finally{fis.close (); Fos.close ();} } else{ System.out.println ("Insufficient balance, please confirm after operation!") "); }} Else{system.out.println ("Wrong side card number!") ");}} catch (FileNotFoundException E1) {e1.printstacktrace ();} catch (IOException E1) {E1.printstacktrace ()}}
The problem is that here, to read the properties of the file first to load the file input IO stream, and then use the properties of the Get method, but if the middle of the process to insert a file output IO stream associated with the text
You will be aware of the contents of the file!
For example, the following wording:
File F = new file ("c://account/" + toaccno + ". txt");
Properties P = new properties ();
FileInputStream FIS = null;
FileOutputStream fos = null;
FIS = new FileInputStream (f);
FOS = new FileOutputStream (f);
P.load (FIS);
Then it clears everything in the file.
In addition, when you want to create a file in depth, the light with File.creatnewfile () is not possible, you must first create a file path, that is, with the new file ("..."). Mkdirs () Create a deep path, and then create
Atm-program about the proprties problem