Atm-program about the proprties problem

Source: Internet
Author: User

                           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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.