Here you can find the source of deleteIfExist(String filePath)
Parameter | Description |
---|---|
filePath | - The path of the file/directory to delete. |
public static void deleteIfExist(String filePath)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013 MCForge.// ww w . j av a 2 s . c o m * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html ******************************************************************************/ import java.io.File; public class Main { /** * Delete the file/directory if exist. * * @param filePath - The path of the file/directory to delete. */ public static void deleteIfExist(String filePath) { File file = new File(filePath); if (file.exists()) { file.delete(); } } /** * Checks whether the specified file exists * * @param filePath - the file path to check */ public static boolean exists(String filePath) { return new File(filePath).exists(); } }