Posted on 2007-02-08 09:41
lixw 阅读(1464)
评论(0) 编辑 收藏
1 public static long checksum(byte[] buf) {
2 try {
3 CheckedInputStream cis = new CheckedInputStream(
4 new ByteArrayInputStream(buf),new Adler32());
5 byte[] tempBuf = new byte[128];
6 while (cis.read(tempBuf) >= 0); return cis.getChecksum().getValue();
7 } catch (IOException e) {
8 return -1;
9 }
10 }