- /**
- * 通过命令删除文件或文件夹(会删除文件夹里所有文件) 只能在windows上使用,如果
- * 在Unix或linux上,则修改相应命令
- *
- * @param _file
- */
- public static void deleteFileByWindowsCommand(File _file) {
- Runtime rt = Runtime.getRuntime();
- String cmd = null;
- try {
- if(_file.isFile()) {
- cmd = "cmd.exe /c del /q/a/f/s "+_file.getAbsolutePath();
- } else {
- cmd = "cmd.exe /c rd /s/q "+_file.getAbsolutePath();
- }
- rt.exec(cmd);
- }catch(IOException e){
- e.printStackTrace();
- }
- }