File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Write and Read Records Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Write and Read Records" Watch "Write and Read Records" New topic

Write and Read Records

Rose Evans
Ranch Hand

Joined: Oct 14, 2004
Posts: 195
You guys...I need some help...
I need to use this file to write a program that will allow me to write or read records of type PetRecord to a file. I need to ask the user if he wants to write or read to a file, and I have to ask for the file name.
And I need to redefine the class PetRecord so that is is serializable.
Im lost....could any of you give me some 'simple' instructions...I'd surely apreciate it.

Thanks a million.

) ) ) )
Nigel Browne
Ranch Hand

Joined: May 15, 2001
Posts: 673
All the information you need is covered here. Read the tutorial, try do something towards your project and then get back to us when your really stuck.
John Dell'Oso
Ranch Hand

Joined: Apr 08, 2004
Posts: 130

In addition to Nigel's advice, I'd also look at tidying up your PetRecord class. In particular, you seem to be following the javabean methodology of getters and setters - as far as your setters are concerned, you should change your the name of your set methods to setXxxxx, where Xxxxx is the name of your class attribute (name, age , weight ). You appear to have quite a bit of repeated code within your class as well. Also, try to keep your constructors together within your class rather than mixing them up with the other methods - it just makes things easier to read.

Rose Evans
Ranch Hand

Joined: Oct 14, 2004
Posts: 195
Thanks you guys...I'll see what I can do.
I agree. Here's the link:
subject: Write and Read Records
It's not a secret anymore!