public static int toInt(byte[] bytes, int offset, int length) { checkBytes(bytes, offset, length, 4); int v = 0; v |= bytes[offset] & 0xFF; v <<= 8; v |= bytes[offset+1] & 0xFF; v <<= 8; v |= bytes[offset+2] & 0xFF; v <<= 8; v |= bytes[offset+3] & 0xFF; return v; }
public static long toUnsignedInt(byte[] bytes, int offset, int length) { checkBytes(bytes, offset, length, 4); long v = 0; v |= bytes[offset] & 0xFF; v <<= 8; v |= bytes[offset+1] & 0xFF; v <<= 8; v |= bytes[offset+2] & 0xFF; v <<= 8; v |= bytes[offset+3] & 0xFF; return v; }
public static int toUnsignedShort(byte[] bytes, int offset, int length) { checkBytes(bytes, offset, length, 2); int v = 0; v |= bytes[offset] & 0xFF; v <<= 8; v |= bytes[offset+1] & 0xFF; return v; }
public static short toUnsignedByte(byte[] bytes, int offset, int length) { checkBytes(bytes, offset, length, 1); short v = 0; v |= bytes[offset] & 0xFF; return v; }
public static int toUnsignedShort(byte[] bytes, int offset, int length) { checkBytes(bytes, offset, length, 2); int v = 0; v |= bytes[offset] & 0xFF; v <<= 8; v |= bytes[offset+1] & 0xFF; return v; }
public static short toShort(byte[] bytes, int offset, int length) { checkBytes(bytes, offset, length, 2); short v = 0; v |= bytes[offset] & 0xFF; v <<= 8; v |= bytes[offset+1] & 0xFF; return v; }
public static short toUnsignedByte(byte[] bytes, int offset, int length) { checkBytes(bytes, offset, length, 1); short v = 0; v |= bytes[offset] & 0xFF; return v; }
public static int toInt(byte[] bytes, int offset, int length) { checkBytes(bytes, offset, length, 4); int v = 0; v |= bytes[offset] & 0xFF; v <<= 8; v |= bytes[offset+1] & 0xFF; v <<= 8; v |= bytes[offset+2] & 0xFF; v <<= 8; v |= bytes[offset+3] & 0xFF; return v; }
public static short toShort(byte[] bytes, int offset, int length) { checkBytes(bytes, offset, length, 2); short v = 0; v |= bytes[offset] & 0xFF; v <<= 8; v |= bytes[offset+1] & 0xFF; return v; }
public static long toUnsignedInt(byte[] bytes, int offset, int length) { checkBytes(bytes, offset, length, 4); long v = 0; v |= bytes[offset] & 0xFF; v <<= 8; v |= bytes[offset+1] & 0xFF; v <<= 8; v |= bytes[offset+2] & 0xFF; v <<= 8; v |= bytes[offset+3] & 0xFF; return v; }
public static byte toByte(byte[] bytes, int offset, int length) { checkBytes(bytes, offset, length, 1); return bytes[offset]; }
public static byte toByte(byte[] bytes, int offset, int length) { checkBytes(bytes, offset, length, 1); return bytes[offset]; }
public static long toLong(byte[] bytes, int offset, int length) { checkBytes(bytes, offset, length, 8); long v = 0; v |= bytes[offset] & 0xFF; v <<= 8; v |= bytes[offset+1] & 0xFF; v <<= 8; v |= bytes[offset+2] & 0xFF; v <<= 8; v |= bytes[offset+3] & 0xFF; v <<= 8; v |= bytes[offset+4] & 0xFF; v <<= 8; v |= bytes[offset+5] & 0xFF; v <<= 8; v |= bytes[offset+6] & 0xFF; v <<= 8; v |= bytes[offset+7] & 0xFF; return v; } }
public static long toLong(byte[] bytes, int offset, int length) { checkBytes(bytes, offset, length, 8); long v = 0; v |= bytes[offset] & 0xFF; v <<= 8; v |= bytes[offset+1] & 0xFF; v <<= 8; v |= bytes[offset+2] & 0xFF; v <<= 8; v |= bytes[offset+3] & 0xFF; v <<= 8; v |= bytes[offset+4] & 0xFF; v <<= 8; v |= bytes[offset+5] & 0xFF; v <<= 8; v |= bytes[offset+6] & 0xFF; v <<= 8; v |= bytes[offset+7] & 0xFF; return v; } }