Publish Your Article Here

Program: How to decompress the compressed objects using zip utility?


This example shows how to decompress the compressed objects. Previous example shows how to compress objects and store it to the file.



public class RetrieveMyObjects {
	public static void main(String a[]){

		FileInputStream fis = null;
		GZIPInputStream gs = null;
		ObjectInputStream ois = null;
		try {
			fis = new FileInputStream("C:/MyObjectStore");
			gs = new GZIPInputStream(fis);
			ois = new ObjectInputStream(gs);
			Mobile m1 = (Mobile) ois.readObject();
			System.out.println(m1.getNumber()+"   "+m1.getOwner());
			Mobile m2 = (Mobile) ois.readObject();
			System.out.println(m2.getNumber()+"   "+m2.getOwner());
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
		} catch (IOException e) {
			// TODO Auto-generated catch block
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
		} finally{
				if(ois != null) ois.close();
				if(fis != null) fis.close();
			} catch (Exception ex){}


class Mobile implements Serializable{
	private String number;
	private String owner;
	public Mobile(String num, String own){
		this.number = num;
		this.owner = own;
	public String getNumber() {
		return number;
	public void setNumber(String number) {
		this.number = number;
	public String getOwner() {
		return owner;
	public void setOwner(String owner) {
		this.owner = owner;

1234566778   JOCK
7686291729   Mike
<< Previous Program | Next Program >>

List of all class sample examples:

  1. How to compress byte array in java?
  2. How to decompress byte array in java?
  3. How to zip a single file?
  4. How to zip multiple files?
  5. How to read zip files entries or file name list?
  6. How to unzip files in java?
  7. How to generate checksum value for for a file in java?
  8. How to compress and store objects using zip utility?
  9. How to decompress the compressed objects using zip utility?
  10. How to zip a file using ZipFile class?
  11. How to compress a file in GZip format?
  12. How to uncompress a file from GZip format?
Knowledge Centre
doPost Vs doGet methods
doGet() method is used to get information, while doPost() method is used for posting information. doGet() requests can't send large amount of information and is limited to 240-255 characters. However, doPost()requests passes all of its data, of unlimited length. A doGet() request is appended to the request URL in a query string and this allows the exchange is visible to the client, whereas a doPost() request passes directly over the socket connection as part of its HTTP request body and the exchange are invisible to the client.
Famous Quotations
I don’t know the key to success, but the key to failure is trying to please everybody.
-- Bill Cosby

About Author

I'm Nataraja Gootooru, programmer by profession and passionate about technologies. All examples given here are as simple as possible to help beginners. The source code is compiled and tested in my dev environment.

If you come across any mistakes or bugs, please email me to [email protected].

Most Visited Pages

Other Interesting Sites

Reference: Java™ Platform Standard Ed. 7 - API Specification | Java™ Platform Standard Ed. 8 - API Specification | Java is registered trademark of Oracle.
Privacy Policy | Copyright © 2020 by Nataraja Gootooru. All Rights Reserved.