jinfeng_wang

G-G-S,D-D-U!

BlogJava 首页 新随笔 联系 聚合 管理
  400 Posts :: 0 Stories :: 296 Comments :: 0 Trackbacks

 

 1package common;
 2
 3import java.io.File;
 4import java.io.IOException;
 5
 6public class RenameFile {
 7 public static void main(String[] args) throws IOException {
 8  String folder = "G:\\shopdata\\\\userdata_bak\\";
 9  renameFileName(new File(folder));
10  System.out.println("over");
11 }

12
13 private static void renameFileName(File folder) throws IOException {
14  System.out.println("folder: "+ folder);
15  File[] files = folder.listFiles();
16  for (int i = 0; i < files.length; i++{
17   File file = files[i];
18   if (file.isDirectory()) {
19    renameFileName(file);
20   }
 else {
21    String oldName=file.getCanonicalPath();
22    if (oldName.endsWith("html")) {
23     return;
24    }

25    File newName = new File(oldName.replace("aspx""html"));
26    boolean bool=file.renameTo(newName);
27    //System.out.println(bool +" : "+newName);
28   }

29  }

30
31 }

32}

33
34
posted on 2007-06-11 10:24 jinfeng_wang 阅读(870) 评论(0)  编辑  收藏 所属分类: java

只有注册用户登录后才能发表评论。


网站导航: