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();
}

相关文章:

  • 2021-08-01
  • 2021-05-23
  • 2021-04-29
  • 2021-09-03
  • 2021-12-21
  • 2021-12-14
  • 2022-12-23
猜你喜欢
  • 2021-09-07
  • 2021-10-09
  • 2021-04-22
  • 2021-07-08
  • 2021-05-22
相关资源
相似解决方案