Posted on 2007-02-08 09:41
lixw 閱讀(1469)
評論(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?}