pro_java thread: How to extend a RandomAccessFile to support the storage and retrieval of arbitrary record data
Hi Harris,
I recently took the Sun certified Java developer's exam and the assignment exactly
included what you are looking for. In a nutshell you only need to create the following
classes. 1) Some class which keeps track of a field i.e. its name and the length in the
random access file.
2) Some class which keeps track of a database record ( One line in the random access
file), the infomation here should include the an array of objects of the filed type, a
database record number, and an array of values for all the fields. The types of all thses
fields could be a String for simplicity.
3) The third and the final class could be the class to manipulate the random access
file. Basically to add a record, to delete a record, to modify a record, to find a record on
the basis of some criteria, to seek a record based on a record number, to create an object of
the type Database, etc.
4) The file itself should be in binary format and should keep administrative
information such as the number of records, the number and names of the fields, the length of
each data record etc. and then all the data. In fron t of each data record you can keep a
byte which tells you whether that record has been deleted or not.
Anant
> Date: Sat, 17 Feb 2001 11:42:14
> From: "Xander Harris" <xanharris@m...>
> To: "Professional Java" <pro_java@p...>
> Subject: [pro_java] How to extend a RandomAccessFile to support the storage and retrieval
of arbitrary record data
> List-Unsubscribe: <mailto:$subst('Email.Unsub')>
>
> Hi!
>
> I have a programming project coming up which requires me to create files
> and enter bus schedule details in them. I need to be able to add, delete,
> update, modify and search records like in a database. I considered using
> JDBC but it seems to be an overkill.
>
> I read an article in JavaWorld which discusses the creation of a database-
> like file with the RandomAccessFile class. My question is how do I exactly
> implement this class and various other classes to create the files I need
> for my project to support the functions I mentioned above? I also need to
> creat a GUI front-end to access those files. The JavaWorld article is so
> confusing until I'm unable to grasp the concept in it.
>
> Please help.
>
> (X)-Harris.