So I have this void I made, Code: public static void resetMap(){ for(Chunk c : Bukkit.getWorld("Game").getLoadedChunks()) { c.unload(false, false); } final File path = Bukkit.getWorld("Game").getWorldFolder(); if (Bukkit.unloadWorld("Game", true)) { System.out.println("Unloaded world"); } else { System.err.println("Couldn't unload world"); } if (path.exists()) { File files[] = path.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { for(File f: files) { if(f.isDirectory()) { path.delete(); } else { f.delete(); } } } else { files[i].delete(); } } } } Though when it is run from a command it only gets rid of level.dat level.dat_mcr level.dat_old session.lock and uid.dat Everything else is still there. I need the WHOLE folder to be deleted, anybody know how to do this?
DJSkepter The directory needs to be empty for that to work. http://docs.oracle.com/javase/7/docs/api/java/io/File.html#delete()
lrdemolition Close but you get the idea. Assuming delete(file) is your method, you also need to check if the file is a file or a directory. If it is a directory, use recursion (make sure you delete the folder too). If not, then just delete the file.