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 閱讀(113) 評論(0)  編輯  收藏 所屬分類: java小程序
          主站蜘蛛池模板: 北安市| 涿州市| 若尔盖县| 泗阳县| 明溪县| 睢宁县| 连城县| 郑州市| 河东区| 华宁县| 工布江达县| 德州市| 荔浦县| 蕲春县| 泗阳县| 安岳县| 沛县| 辛集市| 和平县| 金山区| 永州市| 房产| 界首市| 黔西县| 巧家县| 大兴区| 达拉特旗| 宁津县| 内黄县| 贞丰县| 称多县| 扶风县| 来宾市| 徐闻县| 彭山县| 蕉岭县| 莱阳市| 喀喇沁旗| 蒙自县| 闽清县| 海淀区|