Here you can find the source of deleteFile(String filePath)
Parameter | Description |
---|---|
filePath | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static void deleteFile(String filePath) throws IOException
//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); } }