file的對象僅僅是一個路徑名,它可以存在,也可以不存在
三個構造方法
file(file parent,string child)
file(string parent,string child)
file(string path)
絕對路徑和相對路徑
絕對路徑:從盤符開始
“d:\\aaa\\1.txt”
相對路徑:相對目前項目下的路徑
“子產品\\1.txt”
成員方法
boolean creatnewfile()建立一個人新的檔案夾,不管有沒有字尾名,隻能建立檔案。
boolean mkdir()隻建立單級檔案夾
boolean mkdirs()建立多級檔案夾
boolean delete() 删除檔案夾 不走資源回收筒 隻能删除空文夾 和檔案
檔案的擷取和判斷功能
boolean isdirectory() 抽象路徑名是file否為目錄
boolean isfile() 抽象路徑名是file否為檔案
boolean exists() 抽象路徑名是file是否存在
string getname() 抽象路徑名表示的檔案帶字尾名或者目錄名稱(檔案名字)
string getabsoluttepath()的到全部路徑名稱