返回列表 發帖

檔案與串流 (一)

本帖最後由 tonyh 於 2017-1-14 18:01 編輯

建立資料路徑 C:/a/b/c/ 並在該路徑下建立一新檔案 test.txt

  1. import java.io.File;
  2. public class Ch01 {
  3.         public static void main(String[] args) {
  4.                 File f=new File("C:/a/b/c/test.txt");
  5.                 f.getParentFile().mkdirs();
  6.                 try {
  7.                         f.createNewFile();
  8.                 } catch (Exception e) {}
  9.                 System.out.println(f.getParentFile());
  10.                 System.out.println(f.getAbsolutePath());
  11.         }
  12. }
複製代碼
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

返回列表