用Windows命令删除本地文件夹

private static final String CMMD = "cmd.exe /C RD /S /Q \"%s\"";

public static void deleteFolder(String path)
{
File file = new File(folderPath);
if ( !file.exists() )
{
}

if ( !file.isDirectory() )
{
}

String command = String.format(CMMD, path)

System.out.println( "删除文件夹: " + command );
Process process = Runtime.getRuntime().exec(command);
process.waitFor();
}

你可能感兴趣的:(java)