Here you can find the source of Serialize(Object object)
Parameter | Description |
---|---|
object | Object to be serialize |
Parameter | Description |
---|---|
IOException | an exception |
public static byte[] Serialize(Object object) throws IOException
//package com.java2s; /* //from w w w .j av a 2s . c o m * Created: 12/05/2014 * Author: Luke Salisbury <luke.salisbury@live.vu.edu.au> * Student Number: 1510439 * Course: Programming for Networks * Subject: ECB2123 * License: Creative Commons Attribution-NonCommercial-ShareAlike 4.0 * License URL: http://creativecommons.org/licenses/by-nc-sa/4.0/ * * Implement a Tutoring System that would register tutors interested in * helping students */ import java.io.*; public class Main { /** * Serialize a object * @param object Object to be serialize * @return object as serialize byte array * @throws IOException */ public static byte[] Serialize(Object object) throws IOException { ByteArrayOutputStream byteStream; ObjectOutput output; byte[] objectBytes; byteStream = new ByteArrayOutputStream(); output = new ObjectOutputStream(byteStream); output.writeObject(object); output.close(); objectBytes = byteStream.toByteArray(); return objectBytes; } }