Code example for GZIPOutputStream

Methods: closeflush

0
 
public class ObjectSerialization { 
 
	static public void ObjectToFile(Object o, File out) throws IOException {
		FileOutputStream fos = new FileOutputStream(out);
		GZIPOutputStream gos = new GZIPOutputStream(fos, true);
		ObjectOutputStream oos = new ObjectOutputStream(gos);
		oos.writeObject(o);
		oos.flush();
		gos.flush();
		fos.flush();
		 
		oos.close();
		gos.close();
		fos.close();
	} 
 
	static public Object FileToObject(File in) throws IOException, ClassNotFoundException {
		FileInputStream fis = new FileInputStream(in);
		GZIPInputStream gis = new GZIPInputStream(fis);
Experience pair programming with AI  Get Codota for Java