Originally posted by Philippe Maquet:
Just a comment about the code posted above: why do you write each field value separately? You could prepare a buffer (array of bytes) for the whole record, and then write it in one operation.
Will the grader care?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Originally posted by Dave Gear:
I'm getting more and more confused about this one byte delete flag? It should be saved in the String[] with those other record fields? For example, there is a method: public String[] readRecord(long recNo). The return value of this method is a String[], which represents the whole record. What I'm thinking is I save the one byte delete flag as the first element of this String[]. I can't find out other ways to bundle this flag to the paticular record?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Originally posted by Dave Gear:
In the writeData method, to write the updated record back to db file, the
related code is here:
Originally posted by Andrew Monkhouse:
You have made a mistake with converting back from the String representation of the byte back into the byte[]. If it hadn't been for the other problems, this particular problem may have gone unnoticed, as it only causes problems when you are converting a byte which has more than one digit. If you have a byte which contains the number 45, then convert that into a String, it is stored as the String "45". If you call the getBytes() method on any String, it returns the bytes needed to represent the String. In the case of the String "45", it will return two bytes - the byte representing the "4", and the byte representing the "5" (and this is just ASCII - you could end up with far more complex conversions). What you need to do is create a Byte() from the String, then get the byteValue of it.
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
SCJP, SCJD, SCWCD, SCBCD
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
He was giving me directions and I was powerless to resist. I cannot resist this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|