I want to create and delete a directory using Java, but it isn\'t working.
File index = new File(\"/home/Work/Indexer1\");
if (!index.exists()) {
index.m
As mentioned, Java isn't able to delete a folder that contains files, so first delete the files and then the folder.
Here's a simple example to do this:
import org.apache.commons.io.FileUtils;
// First, remove files from into the folder
FileUtils.cleanDirectory(folder/path);
// Then, remove the folder
FileUtils.deleteDirectory(folder/path);
Or:
FileUtils.forceDelete(new File(destination));