作者CaCaEgg (卡卡小蛋)
看板java
标题[问题] Java IO问题
时间Fri Dec 28 16:45:35 2007
以下是程式码
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
1F:推 supertitler:不是有吗0.0 "test.txt" 12/28 16:49
2F:推 superlubu:b = gzin.read() ... b 不就是放东西的地方吗? 12/28 16:50
3F:→ superlubu:哈... 一楼也是 super 系列 XDrz 12/28 16:50
4F:推 supertitler:原来是说buffer 我误会了Otz 12/28 16:51
5F:→ CaCaEgg:b是int吧 b应该是指read跟write的byte数 不是吗?? 12/28 16:57
6F:推 supertitler:int read() Returns: the next byte of data, 12/28 17:13
7F:→ supertitler:or -1 if the end of the file is reached. 12/28 17:14