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 閱讀(883) 評論(0)  編輯  收藏 所屬分類: java
          主站蜘蛛池模板: 禹城市| 云南省| 浠水县| 苏尼特左旗| 广宗县| 临清市| 巢湖市| 普宁市| 罗田县| 调兵山市| 珲春市| 崇明县| 交城县| 高碑店市| 延安市| 田林县| 富阳市| 平昌县| 唐河县| 陕西省| 突泉县| 正宁县| 抚顺市| 南城县| 弥勒县| 宜兰县| 寿阳县| 韶山市| 鄄城县| 施甸县| 左贡县| 麻江县| 玉门市| 呈贡县| 丰顺县| 兴国县| 定襄县| 阿坝县| 舒城县| 阿拉尔市| 若羌县|