aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes URLyBird Database question 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 "URLyBird Database question" Watch "URLyBird Database question" New topic
Author

URLyBird Database question

Rod Sinclair
Greenhorn

Joined: May 11, 2010
Posts: 22
Hi

Just working on the URLyBird project. The database spec says that fields are null terminated if less than the maximum length. The database file I have is not like this though, it is padded with spaces where a field is less than the maximum length.

I am wondering how to write to the file because if I null terminate a field and start the next field after the null character this will make writing to the database quite tricky as all the other fields will have to move.

If we are allowed to pad the fields with spaces to their maximum length then this makes things alot easier, but the spec does not allow this as far as I can tell.

Just wondering how others have dealt with this.

Thanks in advance.

Rod
Mxolisi Veco
Ranch Hand

Joined: Jan 14, 2010
Posts: 59
Good day Rod.
I set each field to its maximum length before saving the record.

If the fields are not set to their maximum lengths, you will end up with records that do not have the same size. That means you will end up reading or writing to the wrong parts of the database and as a result you will end up with a corrupt database.

Each record must consist of fields that are set to the maximum length so that all the records will be the same length.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5273
    
  13

Rod Sinclair wrote:Just wondering how others have dealt with this.

Did you use the search engine to look for other threads about your question?


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2265
    
    3

Howdy, Rod. Welcome to JavaRanch!

Champion, it's just that this has been discussed a lot before around here, you know... try searching for an answer using the Search engine. I'm sure you'll find a lot of good points in the discussions that went on already!


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Rod Sinclair
Greenhorn

Joined: May 11, 2010
Posts: 22
ok guys. Thanks for the responses. I'll check out the search engine.

Regards


Rod
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URLyBird Database question