Java Path Delete nio delete(String filePath, String fileName)

Here you can find the source of delete(String filePath, String fileName)

Description

delete

License

Open Source License

Declaration

public static void delete(String filePath, String fileName) throws Exception 

Method Source Code


//package com.java2s;

import java.io.File;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
    public static void delete(String filePath, String fileName) throws Exception {

        Path fileToDeletePath = Paths.get(filePath + File.separator + fileName);

        boolean existsFile = fileToDeletePath.toFile().exists();

        if (existsFile) {
            Files.delete(fileToDeletePath);
        }// ww  w . j a v a  2 s.co m

    }
}

Related

  1. delete(Path path)
  2. delete(Path path)
  3. delete(Path root)
  4. delete(Path targetPath)
  5. delete(Path... paths)
  6. delete(String targetFilePath)
  7. deleteAllFilesRecursively(Path path)
  8. deleteContent(Path directory)
  9. deleteEmptyDirsUpTo(Path from, Path to)