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 閱讀(885) 評論(0)  編輯  收藏 所屬分類: java
          主站蜘蛛池模板: 达州市| 金沙县| 潼南县| 买车| 沧源| 维西| 枝江市| 赤壁市| 聊城市| 双鸭山市| 丹凤县| 许昌县| 新绛县| 安龙县| 高雄市| 灵璧县| 长汀县| 克什克腾旗| 禹州市| 嘉善县| 黑山县| 龙门县| 山丹县| 白朗县| 新兴县| 双峰县| 兴宁市| 黄石市| 湖口县| 安庆市| 叶城县| 自治县| 长垣县| 科尔| 北京市| 东港市| 桐庐县| 广州市| 大悟县| 永宁县| 镇巴县|