package com.codeurjava.File;
import java.io.File;
public class Delete_File
{
public static void main(String[] args)
{
try{
File file = new File(c:\\fichier.log”);
if(file.delete()){
System.out.println(file.getName() + 被删除。
}else{
System.out.println(删除操作失败”);
}
文件夹 = new File(c:\\dossier_log”);
if(folder.delete()){
System.out.println(folder.getName() + 被删除。
}else{
System.out.println(删除操作失败”);
}
}catch(Exception e){
e.printStackTrace();
}
}
}
fichier_log.log 被删除。
dossier_log 被删除。
try {资源:
Files.delete(path);
} catch (NoSuchFileException x) {
System.err.format(%s:” + 找不到路径 %n”, path);
} catch (DirectoryNotEmptyException x) {
System.err.format(%s is not empty %n”, path);
} catch (IOException x) {
// 权限问题
System.err.println(x);
}
Please disable your ad blocker and refresh the window to use this website.