Java File Path Delete deleteFile(String filePath)

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

Description

delete File

License

LGPL

Declaration

public static boolean deleteFile(String filePath) 

Method Source Code

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

import java.io.File;

public class Main {
    public static boolean deleteFile(String filePath) {
        boolean isSuc = false;
        try {//from  w  w w.j a  va  2 s  . com
            //get file address
            File file = new File(filePath);
            if (!file.exists()) {
                file.mkdirs();
            }
            //create file list
            File[] files = file.listFiles();
            //batch delete files
            for (int i = 0; i < files.length; i++) {
                files[i].delete();
            }
            isSuc = true;
        } catch (Exception e) {
            isSuc = false;
            e.printStackTrace();
        }
        return isSuc;
    }
}

Related

  1. deletefile(String delpath)
  2. deleteFile(String filePath)
  3. deleteFile(String filePath)
  4. deleteFile(String filePath)
  5. deleteFile(String filePath)
  6. deleteFile(String filePath)
  7. deleteFile(String filePath)
  8. deleteFile(String filePath)
  9. deleteFile(String filePath)