Here you can find the source of serializeToOutputStream(final Serializable ser, final OutputStream os)
Parameter | Description |
---|---|
ser | the ser |
os | the os |
Parameter | Description |
---|---|
IOException | Signals that an I/O exception has occurred. |
private static void serializeToOutputStream(final Serializable ser, final OutputStream os) throws IOException
//package com.java2s; /*/* ww w.ja va 2 s . com*/ * Copyright: Almende B.V. (2014), Rotterdam, The Netherlands * License: The Apache Software License, Version 2.0 */ import java.io.IOException; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.io.Serializable; public class Main { /** * Serialize to output stream. * * @param ser * the ser * @param os * the os * @throws IOException * Signals that an I/O exception has occurred. */ private static void serializeToOutputStream(final Serializable ser, final OutputStream os) throws IOException { ObjectOutputStream oos = null; try { oos = new ObjectOutputStream(os); oos.writeObject(ser); oos.flush(); } finally { oos.close(); } } }