Java Utililty Methods OutputStream Write

List of utility methods to do OutputStream Write

Description

The list of methods to do OutputStream Write are organized into topic(s).

Method

voidserialize(Object obj, OutputStream out)
Serialize to output stream
ObjectOutputStream os = new ObjectOutputStream(out);
os.writeObject(obj);
voidserialize(Object obj, OutputStream out)
serialize
ObjectOutputStream oout = new ObjectOutputStream(out);
oout.writeObject(obj);
oout.flush();
voidserialize(Object object, OutputStream out)
serialize
ObjectOutputStream objectOut = null;
try {
    objectOut = new ObjectOutputStream(out);
    objectOut.writeObject(object);
} finally {
    if (objectOut != null) {
        try {
            objectOut.close();
...
voidserialize(Object value, OutputStream targetOutputStream)
serialize
ObjectOutputStream taos = null;
try {
    taos = new ObjectOutputStream(targetOutputStream);
    taos.writeObject(value);
} catch (Exception e) {
    throw new IllegalStateException(e);
} finally {
    try {
...
voidserialize(OutputStream os, String... params)
Serialize zero or more string parameters, closing the supplied OutputStream.
serializeSpecial(os, params);
os.close();
voidserialize(OutputStream out, Object obj)
serialize
if (out == null)
    throw new NullPointerException("out");
if (obj == null)
    throw new NullPointerException("obj");
ObjectOutputStream objOut = new ObjectOutputStream(out);
objOut.writeObject(obj);
voidserialize(Serializable obj, ByteArrayOutputStream bout)
Serialize the given object into the given stream
try {
    ObjectOutputStream out = new ObjectOutputStream(bout);
    out.writeObject(obj);
    out.close();
} catch (IOException e) {
    throw new IllegalStateException("Could not serialize " + obj, e);
voidserialize(Serializable obj, OutputStream outputStream)

Serializes an Object to the specified stream.

The stream will be closed once the object is written.

if (outputStream == null) {
    throw new IllegalArgumentException("The OutputStream must not be null");
ObjectOutputStream out = null;
try {
    out = new ObjectOutputStream(outputStream);
    out.writeObject(obj);
} catch (IOException ex) {
...
voidserialize(Serializable obj, OutputStream outputStream)
serialize
if (outputStream == null) {
    throw new IllegalArgumentException("The OutputStream must not be null");
ObjectOutputStream out = null;
try {
    out = new ObjectOutputStream(outputStream);
    out.writeObject(obj);
} catch (IOException ex) {
...
voidserialize(Serializable s, OutputStream os)
serialize
ObjectOutputStream out = new ObjectOutputStream(os);
out.writeObject(s);
out.close();