摘要:
public byte[] encoder(Long obj, int maxwidth) throws Exception {if (obj == null) {return new byte[] {};}if (maxwidth > 8) {return new byte[] {};}long value = obj.longValue();byte[] b = new byte[maxwidth];for (int i = 0; i < maxwidth; i++) {b[i] = (byte) ((value >>> ((maxwidth - 1) * 8 阅读全文
摘要:
int mask = 0xff;int temp = 0;long res = 0;int byteslen = bytes.length;if (byteslen > 8) {return Long.valueOf(0L);}for (int i = 0; i < byteslen; i++) {res <<= 8;temp = bytes[i] & mask;res |= temp;}return res;项目中的,目前还是看不明白原理 阅读全文