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("Операция удаления не удалась");
}
Файловая папка = новый 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 {Resources:
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.