Java OutputStream Write serialize(OutputStream os, String... params)

Here you can find the source of serialize(OutputStream os, String... params)

Description

Serialize zero or more string parameters, closing the supplied OutputStream.

License

Open Source License

Parameter

Parameter Description
os a parameter
name a parameter

Exception

Parameter Description
IOException an exception

Declaration

public static void serialize(OutputStream os, String... params)
        throws IOException 

Method Source Code

//package com.java2s;
/**/*  w  w w  . ja  va 2 s .  co m*/
 * Project: Platforms for Collaboration at the AMMRF
 *
 * Copyright (c) Intersect Pty Ltd, 2011
 *
 * @see http://www.ammrf.org.au
 * @see http://www.intersect.org.au
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 * for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * This program contains open source third party libraries from a number of
 * sources, please read the THIRD_PARTY.txt file for more details.
 */

import java.io.IOException;

import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable;

public class Main {
    /**
     * Serialize zero or more string parameters, closing the supplied OutputStream.
     * 
     * @param os
     * @param name
     * @throws IOException
     */
    public static void serialize(OutputStream os, String... params)
            throws IOException {
        serializeSpecial(os, params);
        os.close();
    }

    public static void serialize(OutputStream os, Serializable obj)
            throws IOException {
        serializeSpecial(os, obj);
        os.close();
    }

    private static void serializeSpecial(OutputStream os, Serializable obj)
            throws IOException {
        ObjectOutputStream oos = new ObjectOutputStream(os);
        oos.writeObject(obj);
    }

    /**
     * Serialize zero or more string parameters, but leaves the OutputStream <code>os</code> open for further output.
     * 
     * @param os
     * @param name
     * @throws IOException
     */
    public static void serializeSpecial(OutputStream os, String... param)
            throws IOException {
        ObjectOutputStream oos = new ObjectOutputStream(os);
        oos.writeObject(param);
    }
}

Related

  1. serialize(Object o, OutputStream out)
  2. serialize(Object obj, OutputStream out)
  3. serialize(Object obj, OutputStream out)
  4. serialize(Object object, OutputStream out)
  5. serialize(Object value, OutputStream targetOutputStream)
  6. serialize(OutputStream out, Object obj)
  7. serialize(Serializable obj, ByteArrayOutputStream bout)
  8. serialize(Serializable obj, OutputStream outputStream)
  9. serialize(Serializable obj, OutputStream outputStream)