public static byte [ ] splitInteger ( final int value , final boolean valueInLittleEndian , final byte [ ] buffer ) { final byte [ ] result ; if ( buffer == null || buffer . length < 4 ) { result = new byte [ 4 ] ; } else { result = buffer ; } int tmpvalue = value ; if ( valueInLittleEndian ) { for ( int i = 0 ; i < 4 ; i ++ ) { result [ i ] = ( byte ) tmpvalue ; tmpvalue >>>= 8 ; } } else { for ( int i = 3 ; i >= 0 ; i -- ) { result [ i ] = ( byte ) tmpvalue ; tmpvalue >>>= 8 ; } } return result ; }
Split an integer value to bytes and returns as a byte array .