日新月异
5
公司 :杭州神话信息技术有限公司
部门 :运营中心设计部
岗位 :UI视觉设计
8
关注
15
粉丝
7030
微博
56
被赞
新浪微博
原创达人
友情链接:
找感兴趣的人
精彩内容
热门应用
关于我们
手机玩微博
注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。
import java.io.*;
import java.util.zip.*;
public class exl6 2 {
public static void main{String[] arg) {
ex16_2 obj16_2 = new ex16_2();
obj16_2.doZip("ex16_2.java","ex16_2.gzip")
}
public void doZip(String strIn,String strOut
FileInputStream in;
FileOutputStream out;
GZIPOutputStream gzip;
int nFileLength;
byte[] barray = new byte;
try {
in = new FileInputStream(strIn);
out = new FileOutputStream(strOut);
gzip = new GZIPOutputStream(out);
while((nFileLength = in.read(barray, 0 barray.length)) > 0)
_____________________;
______________________;
gzip.close();
} catch(Exception e) {
e.printStackTrace();
}
}
}
正确答案:gzip.write(barray0nFileLength) in.close()gzip.write(barray,0,nFileLength) in.close() 解析:本题主要考查文件的读写操作。解题关键是熟悉文件读写操作,熟悉GZIP的编程模式,使用FileInputStream读取待压缩的文件,使用GZIPOutputStream进行压缩,除了压缩之外还有解压缩,但是编程的模式一样,一旦压缩数据流被打开,可以象其他数据流一样进行读写。本题中,第1个空,熟练掌握压缩数据流的写操作;第2今