Monday 15 July 2013

java - Using FileWriter and BufferedWriter clearing file for some reason? -


For some reason, when I prepare a new buffetter vaator and a firefighter in my program (even if I write it I have not used anything), I have selected all my text to this file.

The selected file is determined by JeffileCluster

  Public Static File Selected File; Public static zero encrypt () opens an exception {try {// if I do not clear these two authors comment out of the file. Fwitter FW = new firuter (selected file. Absolute file ()); Buffett Vitter BW = New Baffed Vitter (FW); & Lt; String & gt; Line = files.RedAlline (path. (Selected file.stosting), charset. Default charger ()); (String line: line) for {System.out.println (line); Println (AESencrp.encrypt (line)); / * Whether or not the file is commented on, whether it is commented on or not *, not until I create a new fitter and prepare the buffed file is cleaned. * / //bw.write (ASANCRP.Encrep (line)); //bw.close (); }} Hold (IOException e) {e.printStackTrace (); }}   

AESencrp.encrypt I have only one encrypting class, this will not affect it. If I am creating a new firewire and a buffetter, then this loop is not even done (at least I do not believe so, because I did not get the original encryption of the line or the original content of the printed file which was printed I've created a new firrier / buffed vter.) for (string line: line) {System.out.println (line); Println (AESencrp.encrypt (line)); / * Whether or not the file is commented on, whether it is commented on or not *, not until I create a new fitter and prepare the buffed file is cleaned. * / //bw.write (ASANCRP.Encrep (line)); //bw.close (); }

The reason for this is that the creator of FileWriter If the file already exists, then the file is sorted by using it.

If you want to add data instead, use it:

  new flameritter (file, true);    

No comments:

Post a Comment