public void writeInt ( int value ) throws IOException { if ( 4 > buf . length - pos ) { //not enough space remaining byte [ ] arr = new byte [ 4 ] ; arr [ 0 ] = ( byte ) value ; arr [ 1 ] = ( byte ) ( value >> 8 ) ; arr [ 2 ] = ( byte ) ( value >> 16 ) ; arr [ 3 ] = ( byte ) ( value >> 24 ) ; write ( arr , 0 , 4 ) ; return ; } buf [ pos ] = ( byte ) value ; buf [ pos + 1 ] = ( byte ) ( value >> 8 ) ; buf [ pos + 2 ] = ( byte ) ( value >> 16 ) ; buf [ pos + 3 ] = ( byte ) ( value >> 24 ) ; pos += 4 ; }
Write int value into buffer . flush buffer if too small .