返回列表 發帖

檔案與串流 (一)

本帖最後由 tonyh 於 2020-2-15 14:09 編輯

建立資料路徑 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. }
複製代碼

本帖最後由 李知易 於 2018-2-9 21:13 編輯
  1. import java.io.File;
  2. public class Ch000{
  3.         public static void main(String[] args)
  4.         {
  5.                 File f=new File("C:/a/b/c/test.txt");
  6.                 f.getParentFile().mkdirs();
  7.                 try {
  8.                         f.createNewFile();
  9.                 } catch (Exception e) {}
  10.                 System.out.println(f.getParentFile());
  11.                 System.out.println(f.getAbsolutePath());
  12.         }
  13. }
複製代碼
EEEEEEEEEEEEELLLLLLLLLLLLLIIIIIIIIIIIII

TOP

  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. }
複製代碼

TOP

  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. }
複製代碼

TOP

返回列表