java代码,在linux上删除文件

1、其实在linux上和window是一样的

2、path 传入的路径(直接从根目录到你的文件的位置)

public static boolean delFile(String path) {
log.info("进入deFile方法 psth =: "+path);
boolean flag = false;
File file = new File(path);
log.info("操作文件文件,文件列表如下~~__--~~~~~~~~~~~~~~~~~~~:::"+file);
if (!file.exists()) {
return flag;
}
try{
flag = file.delete();
}catch (Exception e){
e.printStackTrace();
}
return flag;
}
原文地址:https://www.cnblogs.com/xiaoyu1994/p/8378763.html