Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URLyBird db format

 
Marcelo Ortega
Ranch Hand
Posts: 528
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to read the contents of my db file but seem to be retreiving strange chars instead of what i was expecting. Observe my code:



I have read that when you use a particular OutputStream to write data to a file, you should use the corresponding InputStream to read it. Is this true? My specs say that the header uses DataInputStream and DataOutputStream for the header. Should i only use these two streams to retrieve header info. But what about the rest of the file?

Why is it that i am getting small squares and crosses (not to mention question marks (?))

Although, even when i try opening the file in Word or OpenOffice, i still get the small squares, but at least i can make out what the rest of the info says.

I am obviously missing a huge point here which i am hoping someone can point out to me.

Thanks and regards,
Marzo.
[ September 27, 2005: Message edited by: Marzo Kaahn ]
 
Tom Henricksen
Author
Ranch Hand
Posts: 144
5
Eclipse IDE jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a little bit of my code that works for me. I am using RAF though.

The db file is a binary file so it isn't all text.
Does this help?
Tom
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marzo
Why is it that i am getting small squares and crosses (not to mention question marks (?))
As Tom pointed out, you are reading a binary file, not a text file. So you will find that some of the header information is not plain text, and the delete flag on each record is also a <int|short> value - not a text character.

If I were to look at the start of my data file, I would see:What you can see here is the left hand column is a base address in hexidecimal going up 16 bytes at a time. The far right hand column is an ASCII representation of the data. The 16 columns inbetween contain the data itself.

Because the start of the file contains header meta-data, it makes no sense to look at it as ASCII. For example, the first field is headerLen which is an int - it makes no sense to look at the int 0x0000009E as ASCII - we are interested in the int value (158). The program I used to print this out determined that these values (0x00, 0x00, 0x00 & 0x9E) do not have representable characters (that is, they are not letters, numbers, or other typeable characters so it represented them by a dot. But other programs might handle them differently, for example:Many of those characters that appeared in the cmd.exe window (for example "♣") are code-set dependant, so you cannot even guarantee the same results on a different copy of Windows 2000. If I tried to open it in Microsoft Word then Microsoft Word will interpret the non-text characters in a Microsoft Word way.

Does this explain what you are seeing?

As for the problem you are experiencing, you are basically trying to treat everything past the magic cookie as a character. You should look at what you are trying to read, and read it appropriately - your instructions should indicate whether you should be trying to read ints or chars or bytes or ....

Regards, Andrew
 
Marcelo Ortega
Ranch Hand
Posts: 528
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tom, thanks Andrew. This has really helped.

Best regards,
Marzo.
 
Marcelo Ortega
Ranch Hand
Posts: 528
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone please answer one of my previous question:


I have read that when you use a particular OutputStream to write data to a file, you should use the corresponding InputStream to read it. Is this true?

My specs say that the header uses DataInputStream and DataOutputStream for the header. Is this pointing something important out to me?


Best regards,
Marzo.
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hallo

I don't know whot you mean but you can use the RandomAccessFile for read/write
, the RAF knows which streamer to use.

I hope this helps.

Regards , Mihai.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic