首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

JAVA怎么强制删除文件呢

2012-10-28 
JAVA如何强制删除文件呢?/** * try to delete given file , try 10 times * @param f * @return true if f

JAVA如何强制删除文件呢?
      /**
* try to delete given file , try 10 times
* @param f
* @return true if file deleted success, nor false;
*/ 
public static boolean forceDelete(File f) 

    boolean result = false; 
     int tryCount = 0; 
     while(!result && tryCount++ <10){ 
    System.gc(); 
    result = f.delete(); 

return result; 
}

热点排行