I tried to use reflection to automate reads from a DataInputStream, as swpalmer suggests in his post, but this failed because :* Class.getDeclaredFields is not bound to return the fields in any particular order, so there is no reliable way to know what field should be read first ;* unsigned types cause troubles : if you store an ushort in an int, reflection will see an int and read 4 bytes instead