Java Delete Directory deleteFiles(File folder)

Here you can find the source of deleteFiles(File folder)

Description

delete Files

License

Open Source License

Declaration

public static void deleteFiles(File folder) 

Method Source Code

//package com.java2s;
/*/*from w w  w . j  a  v  a  2 s .com*/
 * Copyright (c) 2015 Eike Stepper (Berlin, Germany) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Eike Stepper - initial API and implementation
 */

import java.io.File;

public class Main {
    public static void deleteFiles(File folder) {
        if (folder != null) {
            File[] files = folder.listFiles();
            if (files != null) {
                for (File file : files) {
                    delete(file);
                }
            }
        }
    }

    public static void delete(File file) {
        if (file != null) {
            if (file.isDirectory()) {
                deleteFiles(file);
            }

            file.delete();
        }
    }
}

Related

  1. deleteFiles(File directory)
  2. deleteFiles(File directory, String prefix)
  3. deleteFiles(File docFolder)
  4. deleteFiles(File f, boolean del_self)
  5. deleteFiles(File file)
  6. deleteFiles(File folder)
  7. deleteFiles(File parent, boolean incParent)
  8. deleteFiles(File[] files)
  9. deleteFiles(File[] files)