Java ObjectOutputStream Create toBlob(Object obj)

Here you can find the source of toBlob(Object obj)

Description

to Blob

License

Open Source License

Declaration

public static byte[] toBlob(Object obj) throws java.io.IOException 

Method Source Code


//package com.java2s;

import java.io.ObjectOutputStream;

import java.io.ByteArrayOutputStream;

public class Main {
    public static byte[] toBlob(Object obj) throws java.io.IOException {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(obj);//from ww w  . java 2  s .c o m
        oos.flush();
        oos.close();
        bos.close();
        byte[] data = bos.toByteArray();
        return data;
    }
}

Related

  1. toBlob(Serializable object)
  2. toCompressData(Serializable o)
  3. toData(Serializable o)
  4. toInputStream(Object object)