Hi Satish,
Originally posted by Satish Avadhanam:
I'm not sure of how a null character is represented. I tried, but could'nt succeed. Can anyone please throw some light on how a null character is represented in db file?
A null character is represented in Unicode by '\u0000'. The reason you're not seeing any null characters is that there might not be any null characters in the db file. The relevant quote from the assignment instructions is as follows:
All numeric values are stored in the header information use the formats of the DataInputStream and DataOutputStream classes. All text values, and all fields (which are text only), contain only 8 bit characters, null terminated if less than the maximum length for the field. The character encoding is 8 bit US ASCII.
So if you're not finding any null characters that may mean that there aren't any to find. In other words all the fields contain the maximum length for the field. In practice what this means is that the creator of the database file seems to have right-padded each field with spaces, rather than using nulls.
It's not clear to me that this makes any practical difference to your application. I basically ignored the null issue. In other words, if a field value (having a 64 byte length) had the value "Dogs With Tools " I basically treated it within my application as if it were "Dogs With Tools" by using String.trim(). For the purposes of trim the null character and a blank space are both considered white-space and trimmed accordingly. The null character has no particular meaning within the db file. Fields are all fixed-length so they can be read using raf.read(byte[]) (which I would recommend over reading byte-by-byte, by the way) and then trimmed.
Regarding the owner field, yes it is like all the other fields.