File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes reading database file - B&S Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "reading database file - B&S" Watch "reading database file - B&S" New topic

reading database file - B&S

Dan Murphy
Ranch Hand

Joined: Mar 29, 2005
Posts: 126

I'd be intereseted to know which class(es) others have found most useful for reading the database file. The prime candidate to me seems to be RandomAccessFile. In my assignment is says that all text values:

"contain only 8 bit characters, null terminated if less than the maximum length for the field. The characterr encoding is 8 bit US ASCII".

Can I use the readUTF() method of RandomAccessFile to read these string or is there another (better) way?

Thanks in Advance,

Paul Bourdeaux
Ranch Hand

Joined: May 24, 2004
Posts: 783
Hi Dan,

There is no such thing as "8 bit US ASCII". This is a known mistake in the assignment, and you should mention it in your choices.txt. The general consensus here is to use ISO-8859-1 encoding instead.

As far as reading the file, you can use the RAF's read(byte[] b) method and convert it into a String. For example:

“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook
Janelle Smith

Joined: Apr 01, 2005
Posts: 1
I've found the File, FileInputStream and DataInputStream classes to work very well for reading the db file.

SCJP 1.2
I agree. Here's the link:
subject: reading database file - B&S
jQuery in Action, 3rd edition