java - Can not write all the data to txt file -
I have problems writing data to my .txt file. I do not write all the data in my .txt file. I have tried to put everything in the array, but it also does not work.
My code:
BufferedWriter author = faucet; {String line; Process P = RuntimeTet Timetime (). Exec ("ps -a -o pid"); BufferedReader input = new BufferedReader (new InputStreamReader (p.getInputStream ())); While ((line = input. Readline ()) = null () = author = new buffetter (new fleeter ("path ..")); Writer.write (line); Println (line); } Author. Close (); Input.close (); } Hold (exception mistake) {err.printStackTrace (); Println ("Sorry!"); } This only writes the last line of the console.
By creating the object without loosing it during every repetition of the loop, whatever you have done so far Writing is leaving it (using the object you have to use the author to save what you wrote.)
Before you loop, declare the author Required, so change it to BufferedWriter writer = null; {String line; Process P = RuntimeTet Timetime (). Exec ("ps -a -o pid"); BufferedReader input = new BufferedReader (new InputStreamReader (p.getInputStream ())); Author = New buffed waist (new flamer ("Path ..")); While ((line = input. Readline ()) = null (); author; written (line); Println (line); } Author. Close (); Input.close (); } Hold (exception mistake) {err.printStackTrace (); Println ("Sorry!"); } Can I just ask, why are you announcing the writer item of every recovery?
Comments
Post a Comment