Here you can find the source of delete(File file)
Parameter | Description |
---|---|
file | to be deleted |
public static boolean delete(File file)
//package com.java2s; // it under the terms of the GNU General Public License as published by import java.io.File; import java.util.logging.Logger; public class Main { /** jdk1.4 logger */ private static Logger logger = Logger.getLogger("de.axelwernicke.mypod.util"); /**//from w w w .j ava2s . co m * Deletes a file. * If file can not deleted now, its scheduled to be deleted on myPod exit * * @param file to be deleted * @return true, if file was successfully deleted or scheduled to be deleted on exit. */ public static boolean delete(File file) { logger.entering("de.axelwernicke.mypod.util.FileUtils", "delete"); boolean success = false; try { if (file.canRead() && file.canWrite()) { boolean deleted = file.delete(); if (!deleted) { file.deleteOnExit(); } success = true; } } catch (Exception e) { logger.warning("Exception raised: " + e.getMessage()); e.printStackTrace(); } logger.exiting("de.axelwernicke.mypod.util.FileUtils", "delete"); return success; } }