- import java.io.File;
- import java.net.URI;
- import java.net.URISyntaxException;
- import java.net.URL;
- public class RollDateFile {
- public static void rename(File f,String old_v,String new_v ){
- if(f.isDirectory()){
- for(File file :f.listFiles()){
- rename(file,old_v,new_v );
- }
- }else{
- String path = f.getParent();
- String newFile = (f.getName()+"").replaceAll(old_v,new_v);
- String newF = path+File.separator+newFile;
- System.out.println(newF);
- f.renameTo(new File(newF));
- }
- }
- /**
- * @param args
- * @throws Exception
- */
- public static void main(String[] args) throws Exception {
- // TODO Auto-generated method stub
- String path ="E:\\a\\";
- String old_value ="20120828";
- String new_value ="20130124";
- File folder = new File(path);
- rename(folder,old_value,new_value);
- }
- }
文件改名
转载上一篇:ireport客户端打印
下一篇:关闭钩子

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章