Java OutputStream Write serializeToOutputStream(final Serializable ser, final OutputStream os)

Here you can find the source of serializeToOutputStream(final Serializable ser, final OutputStream os)

Description

Serialize to output stream.

License

Apache License

Parameter

Parameter Description
ser the ser
os the os

Exception

Parameter Description
IOException Signals that an I/O exception has occurred.

Declaration

private static void serializeToOutputStream(final Serializable ser, final OutputStream os) throws IOException 

Method Source Code

//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();
        }
    }
}

Related

  1. serializeShortLE(short value, OutputStream outStream)
  2. serializeSpecial(OutputStream os, Serializable obj)
  3. serializeString(OutputStream out, String data)
  4. serializeString(String str, DataOutputStream dout)
  5. serializeTo(OutputStream outputStream, Object obj)
  6. serializeUUID(OutputStream out, UUID id)
  7. writeStream(byte[] data, OutputStream os)
  8. writeStream(byte[] data, OutputStream out)
  9. writeStream(final OutputStream out, final String content, final boolean close)