file f = new file(string pathname);//完整目錄
file f = new file(string parent,string child);//父目錄 加 子目錄
file f = new file(file parent,string child);//父目錄 加 子
//操作方法
boolean createnewfile()
boolean mkdir();
boolean mkdirs();
boolean delete();刪除檔案或者資料夾
boolean renameto(file dest) //重新命名檔案
//判斷方法
boolean isdirectory();
boolean isfile();
boolean exists();
boolean canread();
boolean canwrite();
boolean ishidden();
//獲取方法
string getabsolutepath();
string getpath();
string getname();
long length();
long lastmodified();
string list();//返回目錄下所有的檔案和資料夾的名字
file listfile();返回目錄下所有的檔案和資料夾並轉換成file陣列(方便操作)```
C 之檔案IO操作流
檔案指存放在外部介質上的資料的集合。大家都知道作業系統是以檔案為單位來對資料進行管理的。因此如果你要查詢外部介質的資料,則先要按檔名找到指定檔案,然後再從檔案中讀取資料,如果要把資料存入外部介質中,如果沒有該檔案,則先要建立檔案,再向它輸入資料。由於檔案的內容千變萬化,大小各不相同,為了統一處理,在...
IO流檔案位元組操作
檔案 的拷貝涉及兩個過程 將乙個檔案的內容通過程式讀取出來,然後通過程式將讀取的內容寫入待拷貝的檔案中。在整個過程中,程式起中轉作用,它既有檔案輸入也有檔案輸出的作用。程式使用fileinputstream讀取檔案內容,使用fileoutputstream將內容寫入新的檔案,實現的方法如下 publ...
用IO流對檔案進行操作
一 對檔案進行讀寫操作 1.使用fileinputstream讀取資料 從檔案中讀取資料 public static void fileinputstream throws ioexception system.out.println result in.close 2.把資料寫入檔案中 使用fil...