package com.codeurjava.File;
import java.io.File;
public class Delete_File
{
public static void main(String[] args)
{
try{
파일 파일 = new File("c:\\fichier.log");
if(file.delete()){
System.out.println(file.getName() + "가 삭제되었습니다.");
}else{
System.out.println("삭제 작업 실패");
}
파일 폴더 = 새 파일("c:\\dossier_log");
if(folder.delete()){
System.out.println(folder.getName() + "가 삭제되었습니다.");
}else{
System.out.println("삭제 작업 실패");
}
}catch(예외 e){
e.printStackTrace();
}
}
}
fichier_log.log 삭제됩니다.
dossier_log이 삭제되었습니다.
try {리소스:
Files.delete(path);
} catch (NoSuchFileException x) {
System.err.format("%s:" + "경로를 찾을 수 없음: %n", 경로);
} catch (DirectoryNotEmptyException x) {
System.err.format("%s은(는) 비어 있지 않습니다.%n", 경로);
} catch (IOException x) {
// 권한 문제
System.err.println(x);
}
Please disable your ad blocker and refresh the window to use this website.