(byte[] bytes)
| 3 | public class tool { |
| 4 | |
| 5 | public static long bytesToLong(byte[] bytes) { |
| 6 | long num = 0; |
| 7 | int len = bytes.length; |
| 8 | for (int ix = 0; ix < 8; ++ix) { |
| 9 | num <<= 8; |
| 10 | num |= (bytes[len - ix - 1] & 0xff); |
| 11 | } |
| 12 | return num; |
| 13 | } |
| 14 | |
| 15 | public static byte[] longToBytes(long num) { |
| 16 | byte[] byteNum = new byte[8]; |