Here you can find the source of deleteFileOrDirectory(File file)
Parameter | Description |
---|---|
file | - the file or directory |
Parameter | Description |
---|---|
IOException | an exception |
public static void deleteFileOrDirectory(File file) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2015 CA. All rights reserved. * * This source file is licensed under the terms of the Eclipse Public License 1.0 * For the full text of the EPL please see https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ import java.io.File; import java.io.IOException; public class Main { /**//from w ww. j av a 2 s . c o m * Delete a directory or file * * @param file - the file or directory * @throws IOException */ public static void deleteFileOrDirectory(File file) throws IOException { if (file.delete()) System.out.println("Deleted : " + file.getAbsolutePath()); else System.out.println("Failed to delete : " + file.getAbsolutePath()); } }