Created
February 1, 2018 03:04
-
-
Save achyutdev/f2f1fa2d887653726364494932786cf3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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