Thanks for visiting my blog - I have now moved to a new location at Nature Networks. Url: http://blogs.nature.com/fejes - Please come visit my blog there.

Wednesday, July 9, 2008

Eureka! A working .map reader

Ok.. overly technical post, but it may be useful to anyone who's writing java code, and trying to read binary files.
  1. Don't use a BufferedReader wrapped around your FileInputStream. It modifies the values of the data you get!
  2. 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.
  3. 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.

0 Comments:

Post a Comment

<< Home