JAVA IO - 將對象壓縮到文件和將對象從壓縮文件反序列化。

FileOutputStream fos = new FileOutputStream("c:\\address.gz");
GZIPOutputStream gz = new GZIPOutputStream(fos);
ObjectOutputStream oos = new ObjectOutputStream(gz);

FileInputStream fin = new FileInputStream("c:\\address.gz");
GZIPInputStream gis = new GZIPInputStream(fin);
ObjectInputStream ois = new ObjectInputStream(gis);
address = (Address) ois.readObject();
相關文章
相關標籤/搜索