NX: Reading from the DB

Hi all, I am working on my Contractors assignment. Just started with trying to read from DB File. I saw this in our forum ********************************* The Data class reads from the file using the RandomAccessFile class. All you have to do is use this class to interrogate the database. ***********************************

I think RandomAccessFile is the easier way to read from the DB...Are thery any document, where I can learn more about this and start using it...Please help me on this. Thanks Karthik

Thanks Guys. Today I tried using Random Access File methods to read from the data base. The magic cookie, rec length, no of fields came out ok. And for the no of fields, name length was read, but when I tried to read the field name for the name length...It is not working. I am sure I am doing something wrong. look at my code for this part: char name[] = new char[nameLength],temp; for (int count=0;count<name.length;count++){ temp=raf.readChar(); name[count]=temp; It is returning some strange characters...Please suggest me what is the best way to read the field name and other fields. That would be of great help. Thanks Karthik

The Sun Code Conventions recommends only having one declaration per line. As for your problem .... I think if you check your instructions, you will find that the field names and field contents are stored as bytes. Possibly even US-ASCII 7 bit bytes (which will raise another question I am sure ) You are trying to read a Character which is two bytes long. You need to read in bytes fully, then convert them to a String. Regards, Andrew