zoukankan      html  css  js  c++  java
  • Java修改文件夹名称

    Java修改文件夹名称

    学习了:http://blog.csdn.net/yongh701/article/details/45063833

    进行文件夹名字批量修改,注意,要写全路径;

    package com.stono.thread2.page180;
    
    import java.io.File;
    
    public class ChangeFolderName {
    
        public static void main(String[] args) {
            //D:JavagitworkspaceCodingsrccomstono	hread2
            String path = "D:\Java\gitworkspace\Coding\src\com\stono\thread2";
            File root = new File(path);
            File[] listFiles = root.listFiles();
            for (File file : listFiles) {
                boolean isDirectory = file.isDirectory();
                String name = file.getName();
                String substring = name.substring(4);
                
                if(isDirectory && name.length()==6) {
                    System.out.println(name);
                    System.out.println(substring);
                    file.renameTo(new File("D:\Java\gitworkspace\Coding\src\com\stono\thread2\page0"+substring));
                }
            }
            
        }
    }

    如果路径中有斜线,拷贝到java字符串中,Eclipse会自动进行转义,一个变成了两个\;

    修改之后,发现类里面的包名全部都错了,使用http://www.cnblogs.com/stono/p/8449285.html方法进行了类文件中包名的修改;

  • 相关阅读:
    Java代码是怎么运行的
    Java单例模式
    redis分布式锁实现
    zuul2.0
    配置ssh免密钥登陆多台从机
    Nifi-install-config
    Configure Access to Multiple Clusters
    kubernetes集群搭建(kubeadm,kubelet)
    shell 编程
    系统管理
  • 原文地址:https://www.cnblogs.com/stono/p/8449276.html
Copyright © 2011-2022 走看看