Java File Path Delete deleteFile(File path)

Here you can find the source of deleteFile(File path)

Description

delete File

License

Apache License

Declaration

public static boolean deleteFile(File path) throws FileNotFoundException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;
import java.io.FileNotFoundException;

public class Main {
    public static boolean deleteFile(File path) throws FileNotFoundException {
        if (!path.exists()) {
            throw new FileNotFoundException(path.getAbsolutePath());
        }/*from   ww  w. j a v a 2  s .  c  om*/
        boolean ret = true;
        if (path.isDirectory()) {
            for (File f : path.listFiles()) {
                ret = ret && deleteFile(f);
            }
        }
        return ret && path.delete();
    }
}

Related

  1. deleteEmptDir(String Path, String username)
  2. deleteEmptyDir(File dstPath)
  3. deleteEmptyParents(final File path)
  4. deleteFile(File path)
  5. deleteFile(File path)
  6. deleteFile(final String dirPath, final String fileName)
  7. deleteFile(final String filePathName)
  8. DeleteFile(String _filePath)
  9. deletefile(String delpath)