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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM