首页 > 其他 > 详细

关闭 FileChannel 打开的文件

时间:2016-05-18 10:55:49      阅读:402      评论:0      收藏:0      [点我收藏+]

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

}

}


关闭 FileChannel 打开的文件

原文:http://11615681.blog.51cto.com/11605681/1774618

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!