目录处理工具类 DealWithDir.java
- package com.util;
-
- import java.io.File;
-
- public class DealWithDir {
-
- public static boolean newDir(String path) throws Exception {
- File file = new File(path);
- return file.mkdirs();
- }
-
-
- public static boolean deleteDir(String path) throws Exception {
- File file = new File(path);
- if (!file.exists())
- return false;
- if (file.isFile())
- {
- file.delete();
- return false;
- }
- File[] files = file.listFiles();
- for (int i = 0; i < files.length; i++) {
- deleteDir(files[i].getAbsolutePath());
- }
- file.delete();
-
- return file.delete();
- }
-
-
- public static boolean updateDir(String path, String newPath) throws Exception {
- File file = new File(path);
- File newFile = new File(newPath);
- return file.renameTo(newFile);
- }
-
- public static void main(String d[]) throws Exception{
-
- updateDir("D:\TOOLS\Tomcat 6.0\webapps\BCCCSM\nationalExperiment/22222", "D:\TOOLS\Tomcat 6.0\webapps\BCCCSM\nationalExperiment/224222");
- }
-
-
- }
原文地址:https://www.cnblogs.com/swite/p/5168706.html