public static long bytesToLong(byte[] bytes) {
ByteBuffer buffer = ByteBuffer.allocate(8);
buffer.put(bytes, 0, bytes.length);
buffer.flip();
return buffer.getLong();
}
public static int bytesToInt(byte[] bytes) {
ByteBuffer buffer = ByteBuffer.allocate(4);
buffer.put(bytes, 0, bytes.length);
buffer.flip();
return buffer.getInt();
}
public static byte[] longToBytes(long num) {
ByteBuffer buffer = ByteBuffer.allocate(8);
buffer.putLong(num);
buffer.flip();
return buffer.array();
}