Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.ByteArrayOutputStream;

import java.io.ObjectOutputStream;

public class Main {
    public static byte[] serialize(Object obj) throws Exception {
        //System.err.println(" ser ##"+obj);
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        ObjectOutputStream oout = new ObjectOutputStream(bout);
        oout.writeObject(obj);
        oout.flush();
        byte array[] = bout.toByteArray();
        oout.close();
        bout.close();
        //System.err.println(" ser #"+new String(array));
        return array;
    }
}