public static < T extends Serializable > void serializeToStream ( T obj , OutputStream out ) throws IOException { ObjectOutputStream objOut ; if ( out instanceof ObjectOutputStream ) objOut = ( ObjectOutputStream ) out ; else objOut = new ObjectOutputStream ( out ) ; objOut . writeObject ( obj ) ; objOut . close ( ) ; }
Write one object serilized to a output stream .