1. 程式人生 > >java代碼,在linux上刪除文件

java代碼,在linux上刪除文件

return ret try flag 作文 exc post tac trace

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;
}

java代碼,在linux上刪除文件