Here you can find the source of deleteDirectory(File directory)
Parameter | Description |
---|---|
directory | the directory to delete. |
static public void deleteDirectory(File directory)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.io.File; public class Main { /**/*w w w . j a v a 2 s. c o m*/ * Delete all the files in a directory and then delete the directory itself. * * @param directory the directory to delete. */ static public void deleteDirectory(File directory) { File[] firstDirectoryFiles = directory.listFiles(); if (firstDirectoryFiles != null) { for (File file : firstDirectoryFiles) { file.delete(); } } directory.delete(); } }