• 目录处理工具类 DealWithDir.java


    1. package com.util;  
    2.   
    3. import java.io.File;  
    4.   
    5. /** 
    6.  * 目录处理工具类 
    7.  * 
    8.  */  
    9. public class DealWithDir {  
    10.     /** 
    11.      * 新建目录 
    12.      */  
    13.     public static boolean newDir(String path) throws Exception {  
    14.         File file = new File(path);  
    15.         return file.mkdirs();//创建目录  
    16.     }  
    17.       
    18.     /** 
    19.      * 删除目录 
    20.      */  
    21.     public static boolean deleteDir(String path) throws Exception {  
    22.         File file = new File(path);  
    23.         if (!file.exists())  
    24.             return false;// 目录不存在退出  
    25.         if (file.isFile()) // 如果是文件删除  
    26.         {  
    27.             file.delete();  
    28.             return false;  
    29.         }  
    30.         File[] files = file.listFiles();// 如果目录中有文件递归删除文件  
    31.         for (int i = 0; i < files.length; i++) {  
    32.             deleteDir(files[i].getAbsolutePath());  
    33.         }  
    34.         file.delete();  
    35.           
    36.         return file.delete();//删除目录  
    37.     }  
    38.   
    39.     /** 
    40.      * 更新目录 
    41.      */  
    42.     public static boolean updateDir(String path, String newPath) throws Exception {  
    43.         File file = new File(path);  
    44.         File newFile = new File(newPath);  
    45.         return file.renameTo(newFile);  
    46.     }  
    47.       
    48.     public static void main(String d[]) throws Exception{  
    49.         //deleteDir("d:/ff/dddf");  
    50.         updateDir("D:\TOOLS\Tomcat 6.0\webapps\BCCCSM\nationalExperiment/22222", "D:\TOOLS\Tomcat 6.0\webapps\BCCCSM\nationalExperiment/224222");  
    51.     }  
    52.       
    53.       
    54. }  
  • 相关阅读:
    Mysql高可用MHA
    centos7.2 安装mysql5.7.13
    keepalived+双主实现数据库的高可用
    xtrabackup 完全备份+xtrabacup 增量备份
    xtrabackup 进行 MySQL 数据库备份
    mysql所有备份与恢复
    sysbench压测工具 压测 mysql
    查看CPU性能参数(mpstat, iostat, sar、vmstat)等命令详解
    脚本
    解决 Let’s Encrypt SSL 证书配置错误
  • 原文地址:https://www.cnblogs.com/swite/p/5168706.html
Copyright © 2020-2023  润新知