>Ok.. overly technical post, but it may be useful to anyone who’s writing java code, and trying to read binary files.
- Don’t use a BufferedReader wrapped around your FileInputStream. It modifies the values of the data you get!
- x86 processors are little endian: when you read in four bytes, you have to add them together in the reverse order to create an int.
- Java doesn’t use unsigned variables, so you’ll have to AND all your bytes with 0xff and cast to int to get the correct value.
I’ll just chalk this up to Lessons learned.