Here you can find the source of deleteDirectory(File path)
Parameter | Description |
---|---|
path | a parameter |
static public boolean deleteDirectory(File path)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { /**// w w w.ja v a2 s. c o m * * @param path * @return */ static public boolean deleteDirectory(File path) { if (path.exists()) { File[] files = path.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { deleteDirectory(files[i]); } else { files[i].delete(); } } } return (path.delete()); } /** * List files in a given directory * * */ static public String[] listFiles(String inputdir) { File dir = new File(inputdir); String[] children = dir.list(); if (children == null) { // Either dir does not exist or is not a directory } else { for (int i = 0; i < children.length; i++) { // Get filename of file or directory String filename = children[i]; } } return children; } }