Java File Path Delete deleteFile(String path)

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

Description

deleteFile

License

Open Source License

Parameter

Parameter Description
path a parameter

Declaration

public static int deleteFile(String path) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    /**/*w  ww.j  a v a  2  s . c  o  m*/
     * deleteFile
     * 
     * @param path
     * @return
     */
    public static int deleteFile(String path) {

        int res = 0;

        File temp = new File(path);

        if (temp.exists() && temp.delete()) {
            res = 1;
        }

        return res;
    }

    /**
     * existFile
     * 
     * @param path
     * @return
     */
    public static boolean exists(String path) {

        try {
            File temp = new File(path);
            return temp.exists();
        } catch (Exception e) {
            // ignore
        }
        return false;
    }
}

Related

  1. deleteFile(String path)
  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, String filename)
  9. deleteFile(String strFolderPath, String strFileName)