日期:2014-05-20 浏览次数:20847 次
File file = new File(path);
if(file.exists()){
System.out.println("文件存在");
if(file.delete()){
System.out.println("文件已删除");
}else{
System.out.println("文件"+path+"\\xml\\"+filename+"没有删除删除");
}
}else{
System.out.println("文件在"+path+"\\xml\\"+filename+"没有找到");
}
}catch(Exception e){
System.out.println(e.getMessage());
}
------解决方案--------------------
在多线程环境中,可能会有其他线程操作此文件,所以删不掉,注意程序中操作文件的同步问题。
------解决方案--------------------