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小程序
          主站蜘蛛池模板: 墨竹工卡县| 博客| 全椒县| 漳平市| 普格县| 马关县| 眉山市| 清河县| 得荣县| 读书| 赤峰市| 鄂州市| 江安县| 涿州市| 平邑县| 赤水市| 温宿县| 拉萨市| 辛集市| 页游| 襄垣县| 东乡族自治县| 长兴县| 综艺| 海原县| 牟定县| 邵阳县| 井陉县| 屯昌县| 海门市| 博湖县| 衡南县| 朔州市| 浠水县| 喀喇| 鹤壁市| 荃湾区| 东乌珠穆沁旗| 陇南市| 浦江县| 新邵县|