Java Folder Delete clearFolderContent(String folderName)

Here you can find the source of clearFolderContent(String folderName)

Description

clear Folder Content

License

Open Source License

Declaration

public static void clearFolderContent(String folderName) 

Method Source Code

//package com.java2s;

import java.io.File;

public class Main {
    public static void clearFolderContent(String folderName) {
        File folder = new File(folderName);
        File[] files = folder.listFiles();
        if (files != null) { //some JVMs return null for empty dirs
            for (File f : files) {
                if (f.isDirectory()) {
                    clearFolderContent(f.getAbsolutePath());
                } else {
                    f.delete();//  w  w w.  j ava 2s . c om
                }
            }
        }
        //  folder.delete();
    }
}

Related

  1. clearFolder(File f)
  2. clearFolder(File[] children)
  3. clearFolder(String directoryLocation)
  4. clearFolder(String folder)
  5. clearFolder(String path)
  6. deepDelete(final File file)
  7. emptyAndDelete(File fileOrDir)
  8. emptyDerbyTestDirectory(final String derbyTestDirectory)
  9. emptyFile(final String urlFile)