Java Delete File deleteFile(String fileName)

Here you can find the source of deleteFile(String fileName)

Description

This deletes the specified file.

License

Open Source License

Parameter

Parameter Description
fileName the file name

Exception

Parameter Description
SecurityException if the file is not accessible

Return

true if the file was really deleted, false otherwise

Declaration

public static boolean deleteFile(String fileName) throws SecurityException 

Method Source Code


//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();
    }
}

Related

  1. deleteFile(String fileName)
  2. deleteFile(String fileName)
  3. deleteFile(String fileName)
  4. deleteFile(String fileName)
  5. deleteFile(String filename)
  6. deleteFile(String filename)
  7. deleteFile(String name)
  8. deleteFile(String name)