Java ObjectOutputStream Write saveGZipObject(Object toSave, File file)

Here you can find the source of saveGZipObject(Object toSave, File file)

Description

save G Zip Object

License

Open Source License

Declaration

public static boolean saveGZipObject(Object toSave, File file) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

import java.io.FileOutputStream;
import java.io.IOException;

import java.io.ObjectOutputStream;

import java.util.zip.GZIPOutputStream;

public class Main {
    public static boolean saveGZipObject(Object toSave, File file) {
        FileOutputStream fos = null;
        GZIPOutputStream gos = null;
        ObjectOutputStream oos = null;
        try {//from  ww w . ja v  a  2  s . com
            fos = new FileOutputStream(file);
            gos = new GZIPOutputStream(fos);
            oos = new ObjectOutputStream(gos);
            oos.writeObject(toSave);
            oos.flush();
            oos.close();
            gos.close();
            fos.close();
        } catch (IOException ioe) {
            ioe.printStackTrace();
            return false;
        }
        return true;
    }
}

Related

  1. saveData(HashMap data, String filename)
  2. saveData(Object data, String filename)
  3. saveDate(String path, Object obj)
  4. saveFile(Object o, File file)
  5. saveFile(Object o, String filename)
  6. saveIndex(String path, Serializable obj)
  7. saveInSerFile(String filename, T object)
  8. saveObject(File file, Object o, boolean overwrite)
  9. saveObject(File file, Serializable obj)