public static byte[] convertToBytes(long n) {
        byte[] bytes = new byte[8];

        bytes[7] = (byte) (n);
        n >>>= 8;
        bytes[6] = (byte) (n);
        n >>>= 8;
        bytes[5] = (byte) (n);
        n >>>= 8;
        bytes[4] = (byte) (n);
        n >>>= 8;
        bytes[3] = (byte) (n);
        n >>>= 8;
        bytes[2] = (byte) (n);
        n >>>= 8;
        bytes[1] = (byte) (n);
        n >>>= 8;
        bytes[0] = (byte) (n);

        return bytes;
    }
Writes a long out to an OutputStream.

@param outputStream
           The OutputStream the long will be written to
@param value
           The long 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