Java Directory Delete emptyDir(File dir)

Here you can find the source of emptyDir(File dir)

Description

empty Dir

License

Open Source License

Declaration

public static void emptyDir(File dir) 

Method Source Code

//package com.java2s;
/*-//from   w  w  w .j a  v a 2 s  .co  m
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 2002, 2011 Oracle and/or its affiliates.  All rights reserved.
 *
 */

import java.io.File;

public class Main {
    public static void emptyDir(File dir) {
        if (dir.isDirectory()) {
            String[] files = dir.list();
            if (files != null) {
                for (int i = 0; i < files.length; i += 1) {
                    new File(dir, files[i]).delete();
                }
            }
        } else {
            dir.delete();
            dir.mkdirs();
        }
    }
}

Related

  1. emptyDir(File dir)
  2. emptyDir(File dir)
  3. emptyDir(File dir)
  4. emptyDir(File dir)
  5. emptyDir(File directory)
  6. emptyDir(String dirName)
  7. emptyDir(String path)