Java Utililty Methods ObjectOutputStream Create

List of utility methods to do ObjectOutputStream Create

Description

The list of methods to do ObjectOutputStream Create are organized into topic(s).

Method

byte[]toBlob(Object obj)
to Blob
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(obj);
oos.flush();
oos.close();
bos.close();
byte[] data = bos.toByteArray();
return data;
...
byte[]toBlob(Serializable object)
to Blob
ObjectOutputStream oos = null;
ByteArrayOutputStream bos;
byte[] result = null;
try {
    bos = new ByteArrayOutputStream();
    oos = new ObjectOutputStream(bos);
    oos.writeObject(object);
    result = bos.toByteArray();
...
byte[]toCompressData(Serializable o)
Write the object to a compress byte[].
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Deflater def = new Deflater(Deflater.BEST_COMPRESSION);
DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(baos, def);
ObjectOutputStream oos = new ObjectOutputStream(deflaterOutputStream);
oos.writeObject(o);
oos.close();
return baos.toByteArray();
byte[]toData(Serializable o)
Write the object to a data.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(o);
oos.close();
return baos.toByteArray();
InputStreamtoInputStream(Object object)
to Input Stream
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bout);
out.writeObject(object);
byte[] data = bout.toByteArray();
out.close();
return new ByteArrayInputStream(data);
byte[]toJBytes(Object object)
to J Bytes
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(object);
} catch (java.io.IOException ioe) {
    throw new RuntimeException(ioe.getMessage(), ioe);
} finally {
    if (baos != null)
...
byte[]toSerialized(final Serializable src)
Return the serialized form of the source
if (src == null)
    throw new IllegalArgumentException("src null");
ByteArrayOutputStream bas = new ByteArrayOutputStream(128);
ObjectOutputStream oos = null;
try {
    oos = new ObjectOutputStream(bas);
    oos.writeObject(src);
    oos.flush();
...