1. 程式人生 > >IO流中File物件常用方法

IO流中File物件常用方法

記錄一下學習之路之IO流

File物件常用方法有

boolean canRead()    //接受檔名作為字串

boolean canWrite()    //檢查能否寫入指定檔案

boolean equals(Object obj)    //將指定物件與呼叫函式的物件進行比較

boolean exists()    //測試檔案是否存在

String getAbsolutePath()      //返回此物件表示的檔案的絕對路徑名

String getName()      //返回此物件表示的檔案的名稱

String getParent()     //返回此File物件的路徑名的上一級,如果路徑名沒有上一級,則返回null

boolean isAbsolute()     //測試此File物件表示的檔案是否是絕對路徑名

boolean isDirectory()    //測試此File物件表示的檔案是否是目錄

boolean isFile()      //測試此File物件表示的檔案是否是普通檔案

boolean delete()     //刪除此物件指定的檔案

boolean createNewFile()    //建立空檔案

boolean mkdir()   //建立由該File物件表示的目錄

boolean mkdirs()    //建立包括父目錄的目錄