How do I decompress Java objects?

In the previous example How do I compress Java objects? we have manage to compress Java objects and stored them in file. In this example we will read the file and reconstruct the compressed objects. For the User class you can see in the previous example mentioned above.

package org.kodejava.example.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.zip.GZIPInputStream;

public class UnzipObjectDemo {
    public static void main(String[] args) {
        User admin = null;
        User foo = null;

        try {
            FileInputStream fis = new FileInputStream(new File("user.dat"));
            GZIPInputStream gis = new GZIPInputStream(fis);
            ObjectInputStream ois = new ObjectInputStream(gis);

            admin = (User) ois.readObject();
            foo = (User) ois.readObject();

            ois.close();
            gis.close();
            fis.close();
        } catch (IOException | ClassNotFoundException e) {
            e.printStackTrace();
        }

        System.out.println("Admin = [" + admin + "]");
        System.out.println("Foo = [" + foo + "]");
    }
}

Running the code snippet above will give us the following output:

Admin = [User{id=1, username='admin', password='secret', firstName='System', lastName='Administrator'}]
Foo = [User{id=2, username='foo', password='secret', firstName='Foo', lastName='Bar'}]