看板 java 關於我們 聯絡資訊
※ 引述《CaCaEgg (卡卡小蛋)》之銘言: : 以下是程式碼 : 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"); ByteArrayOutputStream bao = new ByteArrayOutputStream(); byte[] temp = new byte[1]; : int b = 0; while ((b = gzin.read(temp)) != -1 ) //gzin讀1byte到temp中 bao.write(temp); //將temp寫到bao中 byte[] tempArray=bao.toByteArray(); // 將bao物件中資料輸出 // 成byteArray fout.write(tempArray); //寫出至檔案 : gzin.close(); : fout.flush(); : fout.close(); : } : } : 小弟很困惑 : 為什麼gzin.read()讀進來以後 沒有指定要放在什麼地方 : 然而 : fout.write()卻知道要從什麼地方抓資料寫出 : 不知道有沒有哪位高手可以給一下指教 : 謝謝 我沒有debug @@ 憑之前寫的經驗寫的 有錯請指教 -- 最深的祝福是沒有期限的 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.126.54.219 ※ 編輯: reon 來自: 59.126.54.219 (01/03 23:44) ※ 編輯: reon 來自: 59.126.54.219 (01/03 23:45) ※ 編輯: reon 來自: 59.126.54.219 (01/03 23:46)