@ Override public void writeInt ( int n ) throws IOException { byte [ ] intBytes = new byte [ ] { ( byte ) ( ( n >>> 24 ) ^ 0x80 ) , ( byte ) ( n >>> 16 ) , ( byte ) ( n >>> 8 ) , ( byte ) n } ; out . write ( intBytes ) ; }
An int is written by flipping the sign bit and writing it as a big endian int .