Skip to content

Instantly share code, notes, and snippets.

@achyutdev
Created February 1, 2018 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save achyutdev/f2f1fa2d887653726364494932786cf3 to your computer and use it in GitHub Desktop.
Save achyutdev/f2f1fa2d887653726364494932786cf3 to your computer and use it in GitHub Desktop.
import java.io.File;
public class CleanWASTrash {
private static String ROOT_PATH = "C:\\Users\\devkoa1\\Desktop\\test";
public static void main(String... strings) {
try {
System.out.println("-----------------------------Clean WAS started -------------------------------------");
// deleteDirectory(new File(ROOT_PATH + "\\config\\temp\\"));
// deleteDirectory(new File(ROOT_PATH));
// deleteDirectory(new File(ROOT_PATH));
// deleteDirectory(new File(ROOT_PATH));
File file = new File(ROOT_PATH+"\\test123\\\\");
System.out.println("----------------------------Clean WAS Completed -------------------------------------");
} catch (Exception e) {
System.out.println("Error Occur: " + e.getMessage());
}
}
public static boolean deleteDirectory(File directory) throws Exception {
if (directory.isDirectory()) {
File[] subDir = directory.listFiles();
for (int i = 0; i < subDir.length; i++) {
boolean isCompleted = deleteDirectory(subDir[i]);
if (!isCompleted) {
return false;
}
}
}
System.out.println("Deleting : \t\t" + directory.getName());
return directory.delete();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment