in my introduce.html: Data file Format The format of data in the database file is as follows: 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 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. //my code
Hi James-- It looks like the byte pointer is off after the first for-loop iteration in that infinite while loop. Why don't you confirm its location after the readFully operation so you know it actually read in what you expected? Regards, Paul
Sun Certified Java Web Component Developer for J2EE v1.4<br />Sun Certified Java Developer for J2SE v1.4<br />Sun Certified Java Programmer for J2SE v1.4
Thank you for your reply ,Paul. I don't understand why the point to will be incorrect. I got the first "field Flag" as 0 , but I got the second flag as 83?? What's the wrong with my code? What should be done? I read the instructions.html file, it said : ////////////////// 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 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. ////////////////////// each field fixed length at maximum specified in schema information ,so i use readFully() to read the data into the byte array. Anyone who could help me ? Thanks in advance!
Hi James, had a quick look at your problem. It looks like you are reading the flag every time you read a field instead of for each record. Can you try to change your code to: while(true) { pt("fieldFlag : "+db.readByte() ); for(int i =0;i<columnCount;i++){ and see what happens?
I bet with you that the file will look OK. Well, I am a bit ashamed of it, but I spent twice 3 minutes on that code snippet without pointing the issue ... Thank you for having solved the problem. Best, Phil.
Originally posted by Filip Moens: ... had a quick look at your problem. It looks like you are reading the flag every time you read a field instead of for each record. ...
Ack!! You weren't actually supposed to tell him the answer!!!
[ November 10, 2003: Message edited by: Paul Tongyoo ]
Sun Certified Java Web Component Developer for J2EE v1.4<br />Sun Certified Java Developer for J2SE v1.4<br />Sun Certified Java Programmer for J2SE v1.4