File類

常用構造方法:

File(File parent, String child) :根據 parent 抽象路徑名和 child 路徑名字符串創建一個新 File 實例。
File(String pathname) :通過將給定路徑名字符串轉換爲抽象路徑名來創建一個新 File 實例。

File(String parent, String child) :根據 parent 路徑名字符串和 child 路徑名字符串創建一個新 File 實例。

 

常用的方法:

boolean createNewFile() :創建一個新的空文件。

static String separator :當前系統的分隔符。

boolean delete() :刪除文件。注:如果是有輸入輸出流的話要先關閉後才能把文件刪除掉。

boolean exists() :判斷文件是否存在。
boolean mkdir() :創建一個文件夾。

String[] list() :列出全部的文件名稱。

File[] listFiles() :列出完整的路徑。
boolean isDirectory() :判斷給定的路徑是否是目錄。

發佈了21 篇原創文章 · 獲贊 2 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章