public static byte[] convertToBytes(int integer) {
        byte[] byteArray = new byte[4];

        byteArray[0] = (byte) (integer >> 24);
        byteArray[1] = (byte) (integer >> 16);
        byteArray[2] = (byte) (integer >> 8);
        byteArray[3] = (byte) integer;
        return byteArray;
    }
Writes an integer out to an OutputStream.

@param outputStream
           The OutputStream the integer will be written to
@param integer
           The integer to write
@throws IOException
            Thrown if there is a problem writing to the OutputStream
jme3-core/src/plugins/java/com/jme3/export/binary/ByteUtils.java