Results 1 to 10 of 10

Thread: Files writing to it again{resolved}

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    9

    Files writing to it again{resolved}

    i have created a small three field form, and can save the data into a file using writeUTF, but once the program is closed, and then opened again and i write new data, the prev values of the file are washed?
    i understand i need to append, but how?
    thanks
    Last edited by jframe; Jul 23rd, 2003 at 03:46 PM.

  2. #2
    Junior Member
    Join Date
    Jul 2003
    Posts
    20
    try this:
    FileOutputStream(File filename, boolean append)
    if append is true, then it will write and the end of file, else overwrite.

    Sincerely,
    Neptune.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    9
    how will i make it true ? i didnt get ne idea...sorry about that..?
    please help..thanks

  4. #4
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    If you would like to keep the path platform independent then you can use the following as an example.
    Code:
    FileWriter fw = new FileWriter("C:" + File.separator + "Java" + File.separator + "MyFiles" + File.separator +"Text.txt",true);

  5. #5
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Also the only constructors that allows you the ability to append data to a file is FileWriter(String file, boolean append) and FileOutputStream(String file, boolean append). I don't know why Sun didnt add this functionality to the other constructors that allow you to pass in File objects.

  6. #6

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    9
    FileOutputStream(somefile.dat, true append) ?
    this is how?
    i am really a freat at filing

  7. #7

  8. #8

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    9
    FileOutputStream(somefile.dat, true)
    rite?

  9. #9

  10. #10

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    9
    this is what i didnow


    // File data = new File("somefile.dat"); //commented this out

    and made this:..its working now

    ostream = new DataOutputStream(
    new BufferedOutputStream(
    new FileOutputStream("somefile.dat",true)));
    Last edited by jframe; Jul 23rd, 2003 at 03:41 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width