本文**
public string getinputmessage() throws ioexception...
可以返回使用者輸入的資訊,不足之處在於不支援中文輸入,有待進一步改進。
public void copyfile(string src,string dest) throws ioexception...
in.close();
out.close();
} 該方法經過測試,支援中文處理,並且可以複製多種型別,比如txt,xml,jpg,doc等多種格式
public void printstreamdemo()... catch (filenotfoundexception e) ...
}public void stringbufferdemo() throws ioexception......
out.close();
} 該方法可以設定使用何種編碼,有效解決中文問題。
public void renamefile(string path,string oldname,string newname)...
} }
轉移檔案目錄不等同於複製檔案,複製檔案是複製後兩個目錄都存在該檔案,而轉移檔案目錄則是轉移後,只有新目錄中存在該檔案。
public void changedirectory(string filename,string oldpath,string newpath,boolean cover)...
else...
} }
public string fileinputstreamdemo(string path) throws ioexception...
return sb.tostring();
} 在io操作,利用bufferedreader和bufferedwriter效率會更高一點
public string bufferedreaderdemo(string path) throws ioexception...
return sb.tostring(); }
public document readxml(string path) throws documentexception, ioexception...
public void createdir(string path)...
public void createfile(string path,string filename) throws ioexception...
public void delfile(string path,string filename)...
要利用file類的delete()方法刪除目錄時,必須保證該目錄下沒有檔案或者子目錄,否則刪除失敗,因此在實際應用中,我們要刪除目錄,必須利用遞迴刪除該目錄下的所有子目錄和檔案,然後再刪除該目錄。
public void deldir(string path)...
else...
} dir.delete();
} }
java 檔案讀寫 操作
一.獲得控制台使用者輸入的資訊 public string getinputmessage throws ioexception.五.轉移檔案目錄 轉移檔案目錄不等同於複製檔案,複製檔案是複製後兩個目錄都存在該檔案,而轉移檔案目錄則是轉移後,只有新目錄中存在該檔案。public void chang...
java檔案讀寫操作大全
一.獲得控制台使用者輸入的資訊 public string getinputmessage throws ioexception.可以返回使用者輸入的資訊,不足之處在於不支援中文輸入,有待進一步改進。二.複製檔案 1.以檔案流的方式複製檔案 public void copyfile string s...
java檔案讀寫操作大全
一.獲得控制台使用者輸入的資訊 public string getinputmessage throws ioexception.可以返回使用者輸入的資訊,不足之處在於不支援中文輸入,有待進一步改進。二.複製檔案 1.以檔案流的方式複製檔案 public void copyfile string s...