看板 java 關於我們 聯絡資訊
以下是程式碼 import java.io.*; import java.util.zip.*; public class test { public static void main (String[] args) throws IOException { FileInputStream fin = new FileInputStream("test.gz"); GZIPInputStream gzin = new GZIPInputStream(fin); FileOutputStream fout = new FileOutputStream("test.txt"); int b = 0; while ((b = gzin.read()) != -1 ) fout.write(b); gzin.close(); fout.flush(); fout.close(); } } 小弟很困惑 為什麼gzin.read()讀進來以後 沒有指定要放在什麼地方 然而 fout.write()卻知道要從什麼地方抓資料寫出 不知道有沒有哪位高手可以給一下指教 謝謝 -- 沒有人喜歡寂寞, 只是討厭失望…… 村上春樹 『挪威的森林』 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.115.84.211
supertitler:不是有嗎0.0 "test.txt" 12/28 16:49
superlubu:b = gzin.read() ... b 不就是放東西的地方嗎? 12/28 16:50
superlubu:哈... 一樓也是 super 系列 XDrz 12/28 16:50
supertitler:原來是說buffer 我誤會了Otz 12/28 16:51
CaCaEgg:b是int吧 b應該是指read跟write的byte數 不是嗎?? 12/28 16:57
supertitler:int read() Returns: the next byte of data, 12/28 17:13
supertitler:or -1 if the end of the file is reached. 12/28 17:14