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());