Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to check the B&S db file is in correct format?

 
adiratha abhivachan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Readers

I downloaded the assignment db-2x3.db. When I check the contents in the ultraedit editor. I found the first 6 characters are contains only ...... c
haracters.

But In my assignment says

Start of file
4 byte numeric, magic cookie value. Identifies this as a data file
2 byte numeric, number of fields in each record

Schema description section.
Repeated for each field in a record:
1 byte numeric, length in bytes of field name
n bytes (defined by previous entry), field name
1 byte numeric, field length in bytes
end of repeating block

Data section.
Repeat to end of file:
1 byte flag. 00 implies valid record, 0xFF implies deleted record
Record containing fields in order specified in schema section, no separators between fields, each field fixed length at maximum specified in schema information

End of file

I didn't find the magic cookie value in the file.

Any ideas how to verify the file format is correct?

Thanks
Suresh
 
Olena Golub
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Suresh,
try to read your file from Java
In my assignment I use RandomAccessFile to read the db file.



Hope that will help you.
Olena
[ April 04, 2005: Message edited by: Olena Golub ]
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read mine in a hex editor and it displayed as listed in the schema. Perhaps the editor you have was set to display a period (.) for a non-print character? It's also easy in Java to write a simple GUI to display in hex.
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Set ultraedit to display in hex and you will be able to read it just fine. I had the same version as you, and didn't have any problems.
 
adiratha abhivachan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to all.. Let me check the db once again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic