Re: [問題] Java IO問題

看板java作者時間18年前 (2008/01/03 23:44), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《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)
文章代碼(AID): #17VGBFFz (java)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
文章代碼(AID): #17VGBFFz (java)