Java File Path Delete deleteAllFile(String folderPath)

Here you can find the source of deleteAllFile(String folderPath)

Description

delete All File

License

Open Source License

Declaration

public static boolean deleteAllFile(String folderPath) throws IOException 

Method Source Code

//package com.java2s;
/**/*from w  ww . java 2  s . c om*/
 * Project: isor
 * 
 * File Created at 2013-7-8
 * $Id$
 * 
 * Copyright 2008 Shensuoyao.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Shensuoyao Company. ("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 Shensuoyao.com.
 */

import java.io.File;
import java.io.IOException;

public class Main {

    public static boolean deleteAllFile(String folderPath) throws IOException {
        boolean bool = false;
        File file = new File(folderPath);
        if (!file.exists())
            return false;
        if (!file.isDirectory())
            return false;
        String[] tempList = file.list();
        File temp = null;
        for (int i = 0; i < tempList.length; i++) {
            if (folderPath.endsWith(File.separator)) {
                temp = new File(folderPath + tempList[i]);
            } else {
                temp = new File(folderPath + File.separator + tempList[i]);
            }
            if (temp.isFile())
                temp.delete();
        }
        return bool;
    }
}

Related

  1. deleteAll(File path)
  2. deleteAll(File path)
  3. deleteAll(File path)
  4. deleteAllFile(final File dir)
  5. deleteAllFile(String directory)
  6. deleteAllFile(String path)
  7. deleteAllFile(String path)
  8. deleteAllFiles()
  9. deleteAllFiles(File dir)