Here you can find the source of deleteFile(String fileName)
static void deleteFile(String fileName)
//package com.java2s; /******************************************************************************* * Copyright (c) 2001, 2007 Oracle Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * /*from www.j a va 2 s . c om*/ * Contributors: * Oracle Corporation - initial API and implementation *******************************************************************************/ import java.io.File; public class Main { static void deleteFile(String fileName) { File f = new File(fileName); if (f.exists()) { f.delete(); if (f.exists()) f.deleteOnExit(); } } }