FileInputStream in = new FileInputStream(file);
FileChannel ch = in.getChannel();
MappedByteBuffer byteBuffer = ch.map(FileChannel.MapMode.READ_ONLY, 0,
file.length());
messageDigest.update(byteBuffer);
/*
* in.close(); in = null; byteBuffer.clear(); byteBuffer = null;
* ch.close(); ch = null;
*/
if(file.length() > 0){
Method getCleanerMethod;
sun.misc.Cleaner cleaner = null;
try {
getCleanerMethod = byteBuffer.getClass().getMethod("cleaner",
new Class[0]);
getCleanerMethod.setAccessible(true);
cleaner = (sun.misc.Cleaner) getCleanerMethod
.invoke(byteBuffer, new Object[0]);
cleaner.clean();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return bufferToHex(messageDigest.digest());
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。