See if Byte.parseByte() would help. You'd read two characters, eg "0A", and parseByte to get a byte with value of 10 and put a bunch of those bytes into an array or write them right to the output file.
Scanner looks like it can do this on the fly. Set the radix to 16 and get nextByte. I wonder if you couldn't use Scanner for the whole file ... do you always know what's coming next? [ January 05, 2006: Message edited by: Stan James ]
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
It looks like you have all the information you need, you just need to approach it methodically. About the only thing that could trip you up is "byte order" - you need to figure out if (for example) a short int is written with the low order byte first or the high order byte first.
In Java math with bytes you must remember that each byte gets promoted to an int - with sign extension! - before anything else happens so you will see stuff full of masking with 0xff and shifting by 8 bits when assembling a Java int value from a byte array. Example:
short n = (0xff & b) + ((0xff) & b) << 8 ;
where the byte order is low byte first. (off the top of my head, hope I got it right)
If this was my problem I would write a class for each of your identifiable data chunks, each having the methods to extract a value as needed and to read or write the required byte.
Police line, do not cross. Well, this tiny ad can go through: