Java Path Delete nio deleteFile(String filePath)

Here you can find the source of deleteFile(String filePath)

Description

Deletes a file if the file exists in the given filePath

License

Open Source License

Parameter

Parameter Description
filePath a parameter

Exception

Parameter Description
IOException an exception

Declaration

public static void deleteFile(String filePath) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /**/*from   ww  w  . j a va 2s . c o  m*/
     * Deletes a file if the file exists in the given filePath
     * @param filePath
     * @throws IOException
     */
    public static void deleteFile(String filePath) throws IOException {
        Path path = Paths.get(filePath);
        Files.deleteIfExists(path);
    }
}

Related

  1. deleteEmptyParentDirs(Path pkgDirPath, Path repoPath)
  2. deleteFile(Path p)
  3. deleteFile(Path path)
  4. deleteFile(Path path)
  5. deleteFile(Path path)
  6. deleteFile(String path)
  7. deleteFilesIfExist(Path... files)
  8. deleteFilesIgnoringExceptions(final Path... files)
  9. deleteFilesRecursively(Path path, final PathMatcher pathMatcher)