摘要: 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 阅读全文
posted @ 2012-04-27 15:30 菜鸟王子 阅读(1054) 评论(0) 推荐(0) 编辑
摘要: 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;项目中的,目前还是看不明白原理 阅读全文
posted @ 2012-04-27 15:08 菜鸟王子 阅读(1657) 评论(0) 推荐(0) 编辑