All Downloads are FREE. Search and download functionalities are using the official Maven repository.

kg.apc.io.BinaryUtils Maven / Gradle / Ivy

There is a newer version: 0.2
Show newest version
package kg.apc.io;

public class BinaryUtils {

    public static byte[] shortToByteArray(short value) {
        byte[] result = new byte[2];
        result[1] = (byte) (value >>> 8);
        result[0] = (byte) value;
        return result;
    }


    public static long twoBytesToLongVal(byte byte1, byte byte2) {
        long short1 = (long) (byte1 & 0xFF); // God knows, how long I searched for this...
        long short2 = (long) (byte2 & 0xFF);

        return (short2 << 8) | short1;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy