Sponsors: Michael Fertik - Best JAVA Web hosting Company & 30% off


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-19-2010, 12:21 PM
Member
 
Join Date: Dec 2009
Posts: 4
Rep Power: 0
Hippo is on a distinguished road
Red face How to Append in file ?
Hello .. i am using PrintWriter for writing some data in a file.
Now problem is that , if at some time application is stopped , while restarting , it starts writing in file from starting. (It rewrites)
Is there any solution for this ?
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 03-19-2010, 12:42 PM
Senior Member
 
Join Date: Sep 2008
Location: Voorschoten, the Netherlands
Posts: 3,337
Rep Power: 5
JosAH is on a distinguished road
Default
Originally Posted by Hippo View Post
Hello .. i am using PrintWriter for writing some data in a file.
Now problem is that , if at some time application is stopped , while restarting , it starts writing in file from starting. (It rewrites)
Is there any solution for this ?
Your PrintWriter must be wrapped around a FileWriter or a FileOutputStream now; the last two classes have constructors that make them append to any already present content of a file. Read their API documentation.

kind regards,

Jos
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 03-19-2010, 01:50 PM
j2me64's Avatar
Senior Member
 
Join Date: Sep 2009
Location: Zurich, Switzerland
Posts: 484
Rep Power: 2
j2me64 is on a distinguished road
Default
Originally Posted by JosAH View Post
Read their API documentation.

right, the api documentation about FileWriter constructor parameters is saying

Code:
Parameters:
fileName - String The system-dependent filename.
append - boolean if true, then data will be written to the end of the file rather than the beginning.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Tags
append, file, printwriter

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Browse for and append looselispssinkships New To Java 0 03-19-2010 10:25 AM
How can we append the stirng in excel using jxl javasaravanan Advanced Java 0 11-26-2009 09:01 AM
append variables to a text file ddatta8 New To Java 2 01-02-2009 10:17 AM
Can we append more than 255 chars to <a href>?? freddieMaize Advanced Java 22 07-18-2008 04:04 PM
JLabel append? Jononomous New To Java 0 04-07-2008 07:41 PM


Java Forums is supported by the best jsp hosting.

All times are GMT +2. The time now is 05:26 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org