讀取文字檔案:
1private
static
void
iodemo1()
10filereader.close();
11 } catch
(filenotfoundexception e) catch
(ioexception e)
16 }
複製二進位制檔案:
1private
static
void
iodemo2()
10 fw.flush();//
杯子中沒有飲料不代表飲料已喝完,此方法就是清空吸管中的飲料
11fw.close();
12fr.close();
13 } catch
(filenotfoundexception e) catch
(ioexception e)
18 }
使用緩衝流複製二進位制檔案:
1private
static
void
iodemo3()
12bos.flush();
13bos.close();
14bis.close();
15 } catch
(filenotfoundexception e) catch
(ioexception e)
20 }
資料流傳遞資料:
1private
static
void
iodemo4() catch
(ioexception e)
20 }
printstream:參考
objectstream:
1private
static
void
iodemo5() catch
(exception e) finally
catch
(exception e) 29}
30}31//
實現serializable的作用是可以將物件儲存在檔案中用於傳輸
32class student implements
serializable
4445
public
string getname()
4849
public
void
setname(string name)
5253
public
intgetid()
5657
public
void setid(int
id)
6061
public
float
getscore()
6465
public
void setscore(float
score)
68 }
java基礎之io流
1.四大抽象基類 位元組流 inputstream outputstream 字元流 writer reader 位元組輸出流寫檔案用其子類fileoutputstream類 構造 fileoutputstream file file 傳遞file物件包裝檔案 string name 傳遞字串型別檔...
java基礎之IO流
io流概念 輸入流 把能夠讀取乙個位元組序列的物件稱為輸入流。輸出流 把能夠寫乙個位元組序列的物件稱為輸出流。通俗理解 對於初學者,可能常常不清楚何時該用輸入流,何時該用輸出流。本人將這兩個流記為 讀入寫出 那麼我就清楚輸入流就有read 讀 方法,輸出流就有write 寫 方法。然後,再思考 讀入...
java基礎(九) IO流
1.io流的意義 處理裝置之間的資料傳輸 硬碟 記憶體 讀 input 記憶體 硬碟 寫 output 2.file類常用方法 新建檔案 file file new file d aaa 1.txt file file new file d system.getproperty file.separ...