Untitled

 avatar
unknown
plain_text
a month ago
629 B
1
Indexable
import java.io.IOException;
import java.nio.file.*;
public class RemoveFile{
    public static void main(String[] args){
        try{
            Files.deleteIfExists(Paths.get("C:/Files/demo.txt"));
            System.out.println("demo.txt successfully deleted.");
        }
        catch(IOException e){
            System.out.println("demo.txt not found.");
        }
        try{
            Files.delete(Paths.get("C:/Files/test.txt"));
            System.out.println("test.txt successfully deleted.");
        }
        catch(IOException e){
            System.out.println("test.txt not found.");
        }
      
    }
}

Leave a Comment