march alex's blog
          hello,I am march alex
          posts - 52,comments - 7,trackbacks - 0
          FileCreate類的createFile方法用于創建一個新文件。
          file.mkdirs()方法可用于地柜的創建目錄。
          main方法用于測試。
          import java.io.File;
          import java.io.IOException;


          public class FileCreate {
              public static void createFile(String path, String filename) throws Exception {
                  File file = new File(path);
                  if(!file.exists()) {
                      file.mkdirs();
                  }
                  file = new File(path, filename);
                  if(!file.exists()) {
                      file.createNewFile();
                  }
              }
              public static void main(String[] args) throws Exception {
                  createFile("D:\\test", "hello.txt");
              }
          }
          posted on 2015-02-13 14:38 marchalex 閱讀(116) 評論(0)  編輯  收藏 所屬分類: java小程序
          主站蜘蛛池模板: 黑水县| 甘孜| 普兰店市| 迭部县| 涿州市| 扶风县| 林甸县| 中西区| 长岭县| 安仁县| 黄平县| 台湾省| 北海市| 崇阳县| 扶绥县| 婺源县| 荔浦县| 仙桃市| 太和县| 二手房| 栖霞市| 金秀| 边坝县| 濮阳市| 新河县| 灵川县| 彰武县| 双牌县| 曲沃县| 安丘市| 临泽县| 修武县| 黎平县| 五寨县| 大悟县| 偃师市| 普兰县| 日喀则市| 张掖市| 富宁县| 武威市|