不用在意什么意思,关键几句明白就行,代码分为3段
第一段
ReadEmployee.java
import java.io.*;
import java.util.zip.*;
public class ReadEmployee {
public static void main(String argv[]) throws
Exception{
//deserialize objects sarah and sam
FileInputStream fis = new FileInputStream("db");
GZIPInputStream gs = new GZIPInputStream(fis);
ObjectInputStream ois = new ObjectInputStream(gs);
Employee sarah = (Employee) ois.readObject();
Employee sam = (Employee) ois.readObject();
//print the records after reconstruction of state
sarah.print();
sam.print();
ois.close();
fis.close();
}
}
这个大意是读取ZIP压缩文件中的数据
第二段:
GZIPOutputStream gzipout = new
GZIPOutputStream(socket.getOutputStream());
ObjectOutputStream oos = new
ObjectOutputStream(gzipout);
oos.writeObject(obj);
gzipos.finish();
通过SOCKET 的输出流把ZIP文件发送出去
第三段 就是剩下的
意思是客户端 读取服务器SOCKET输出的ZIP文件流