Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.IOException;
import java.nio.file.DirectoryNotEmptyException;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
    public static void main(String[] args) throws Exception {
        Path p = Paths.get("C:\\Java_Dev\\test1.txt");

        try {
            Files.delete(p);
            System.out.println(p + "  deleted successfully.");
        } catch (NoSuchFileException e) {
            System.out.println(p + "  does  not  exist.");
        } catch (DirectoryNotEmptyException e) {
            System.out.println("Directory " + p + "  is not  empty.");
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}