Thinking

快乐编程,开心生活
posts - 21, comments - 27, trackbacks - 0, articles - -5
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

计算字节数组的校验和

Posted on 2007-02-08 09:41 lixw 阅读(1446) 评论(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 }


只有注册用户登录后才能发表评论。


网站导航: