Here you can find the source of deleteDirByDoc(String path)
public static int deleteDirByDoc(String path)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.IOException; public class Main { public static int deleteDirByDoc(String path) { path = path.replaceAll("/", "\\\\"); path = path.replaceAll("\\\\\\\\", "\\\\"); if (new File(path).exists()) { Runtime runtime = Runtime.getRuntime(); try { runtime.exec("cmd /c rd /s/q " + path); return 0; } catch (IOException e) { return 1; }//from w ww . j a va 2 s . c om } else { return 2; } } }