Java File Path Delete deleteDirByDoc(String path)

Here you can find the source of deleteDirByDoc(String path)

Description

delete Dir By Doc

License

Apache License

Declaration

public static int deleteDirByDoc(String path) 

Method Source Code

//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;
        }
    }
}

Related

  1. deleteDir(File path)
  2. deleteDir(File path)
  3. deleteDir(final String path)
  4. deleteDir(String path)
  5. deleteDir(String path)
  6. deleteDirectory(File directoryPath)
  7. deleteDirectory(File path)
  8. deleteDirectory(File path)
  9. deleteDirectory(File path)