Java File Path Delete deleteFile(String path)

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

Description

Delete file according to a path.

License

Apache License

Parameter

Parameter Description
path - file path

Return

- true if delete successfully, otherwise false.

Declaration

public static boolean deleteFile(String path) 

Method Source Code

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

import java.io.File;

public class Main {
    /**/*from w ww  .  jav  a  2s.  c  om*/
     * Delete file according to a path.
     * 
     * @param path
     *            - file path
     * @return - true if delete successfully, otherwise false.
     */
    public static boolean deleteFile(String path) {
        File file = new File(path);
        return deleteFile(file);
    }

    /**
     * Delete file.
     * 
     * @param file
     *            - deleted file
     * @return - true if delete successfully, otherwise false.
     */
    public static boolean deleteFile(File file) {
        boolean flag = false;
        if (file.exists() && file.isFile()) {
            file.delete();
            flag = true;
        }
        return flag;
    }
}

Related

  1. deleteFile(String p_filePath, boolean pb_recursive)
  2. deleteFile(String path)
  3. deleteFile(String path)
  4. deleteFile(String path)
  5. deleteFile(String path)
  6. deleteFile(String path)
  7. deleteFile(String path)
  8. deleteFile(String path)
  9. deleteFile(String path)