Here you can find the source of deleteFile(String fileName)
public static void deleteFile(String fileName) throws IOException
//package com.java2s; /*//from www . jav a 2s .com * Copyright (c) 2010-2012 Research In Motion Limited. All rights reserved. * * This program and the accompanying materials are made available * under the terms of the Apache License, Version 2.0, * which accompanies this distribution and is available at * * http://www.apache.org/licenses/LICENSE-2.0 * * To use this code further you must also obtain a valid copy of * InstallAnywhere 8.0 Enterprise/resource/IAClasses.zip * Please visit http://www.flexerasoftware.com/products/installanywhere.htm for the terms. * * Additionally, for the Windows(R) installer you must obtain a valid copy of vcredist_x86.exe * Please visit http://www.microsoft.com/en-us/download/details.aspx?id=29 for the terms. * */ import java.io.File; import java.io.IOException; public class Main { public static void deleteFile(String fileName) throws IOException { deleteFile(new File(fileName)); } public static void deleteFile(File file) throws IOException { if (file.exists() && file.isFile()) { if (!file.delete()) { System.out.println("Fail to delete file:" + file.getCanonicalPath()); } } } }