The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
February 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

ObjectInputStream any help?

Posted by richard on February 17, 2001 at 1:07 PM

> I want to write a program in java to read from a flatfile created in Delphi.

> Is there any other way of doing it in java than (say) the readInt() method in RandomAccessFile, followed by readChar(), followed by readChar(), etc etc. Can I create a TItem_Rec class and read the file directly into that?


One of the easier ways to handle reading and writing records in Java is to create a Class that implements a record structure (containing only fields - data members, and accessor and mutator methods - get and set). Then, in an application you can create an array of such objects and write the entire array to file with an ObjectOutputStream. You only have to make your record-type class implement java.io.serializable to do this.

I could send an example if you want.

regards

richard




Replies:
  • Thanks barn February 19, 2001 at 6:28 AM (0)

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us