HI, io problem..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ShaveDave27
    New Member
    • Apr 2007
    • 22

    HI, io problem..

    Hi,
    i've created a class Person which asks for the firstname, surname, month and day (of birth). It does this from the keyboard and i have tried to output the input into a file using PrintWriter. It all works fine exept i can only save one object into the file.

    F = firstname S = surname m = month d = day

    outFile.println (F+" "+S+" "+m+" "+d+" \n");

    everytime i make a new person object the old person object is replaced in the file.

    Any ideas??

    Dave
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by ShaveDave27
    Hi,
    i've created a class Person which asks for the firstname, surname, month and day (of birth). It does this from the keyboard and i have tried to output the input into a file using PrintWriter. It all works fine exept i can only save one object into the file.

    F = firstname S = surname m = month d = day

    outFile.println (F+" "+S+" "+m+" "+d+" \n");

    everytime i make a new person object the old person object is replaced in the file.

    Any ideas??

    Dave
    Use a FileWriter for writing to files and make sure you open the file in append mode

    Comment

    Working...