Here you can find the source of deleteFile(String fileName)
Parameter | Description |
---|---|
fileName | the file name |
Parameter | Description |
---|---|
SecurityException | if the file is not accessible |
public static boolean deleteFile(String fileName) throws SecurityException
//package com.java2s; import java.io.*; public class Main { /**/*from www .ja v a2 s . c o m*/ * This deletes the specified file. If the file is still open, it won't be deleted and false * is returned. * @param fileName the file name * @return true if the file was really deleted, false otherwise * @throws SecurityException if the file is not accessible */ public static boolean deleteFile(String fileName) throws SecurityException { File file = new File(fileName); return file.delete(); } }