Java File Path Delete delete(String filePath)

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

Description

delete

License

Open Source License

Declaration

public static boolean delete(String filePath) 

Method Source Code


//package com.java2s;
/*/* ww w. ja  va2 s .c o  m*/
 * Copyright 2017 Alibaba.com All right reserved. This software is the
 * confidential and proprietary information of Alibaba.com ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with Alibaba.com.
 */

import java.io.File;

public class Main {
    public static boolean delete(File file) {
        if (file.isFile()) {
            return file.delete();
        } else {
            boolean flag = true;
            for (File item : file.listFiles()) {
                flag = flag & delete(item);
            }
            flag = flag & file.delete();
            return flag;
        }
    }

    public static boolean delete(String filePath) {
        File file = new File(filePath);
        return delete(file);
    }
}

Related

  1. delete(File path)
  2. delete(File path)
  3. delete(File path, String... exclude)
  4. delete(final File path)
  5. delete(String fileNameWithFullPath)
  6. delete(String filePath)
  7. delete(String filePath)
  8. delete(String filePath)
  9. delete(String filePath, boolean recursive)