Results 1 to 3 of 3
  1. #1
    Hippo is offline Member
    Join Date
    Dec 2009
    Posts
    4
    Rep Power
    0

    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 ?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,344
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote 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

  3. #3
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default

    Quote Originally Posted by JosAH View Post
    Read their API documentation.

    right, the api documentation about FileWriter constructor parameters is saying

    Java 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.

Similar Threads

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •