Java File Delete nio delete(File file)

Here you can find the source of delete(File file)

Description

delete

License

Apache License

Declaration

public static boolean delete(File file) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.*;
import java.nio.file.*;

public class Main {
    public static boolean delete(File file) {
        return delete(file.toPath());
    }//from w w w. ja  v  a 2s  .  c om

    public static boolean delete(String path) {
        Path p = Paths.get(path);
        return delete(p);
    }

    public static boolean delete(Path path) {
        try {
            return Files.deleteIfExists(path);
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }
    }
}

Related

  1. delete(File f)
  2. delete(File file)
  3. delete(File file)
  4. delete(File file)
  5. delete(File file)
  6. delete(File file)