Here you can find the source of deleteFile(String path)
Parameter | Description |
---|---|
path | Path to delete |
Parameter | Description |
---|---|
IOException | If the operation fails. |
public static void deleteFile(String path) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; public class Main { /**//w w w . j a va 2s . c om * Convenience function to delete a file. * * @param path Path to delete * @throws IOException If the operation fails. */ public static void deleteFile(String path) throws IOException { if (!new File(path).delete()) throw new IOException(String.format( "Unable to delete file '%s'", path)); } }