Here you can find the source of serialize(Serializable... objects)
public static final byte[] serialize(Serializable... objects)
//package com.java2s; /*// w w w .j a v a 2 s . c o m * Copyright 2010 The Portico Project * * This file is part of portico. * * portico is free software; you can redistribute it and/or modify * it under the terms of the Common Developer and Distribution License (CDDL) * as published by Sun Microsystems. For more information see the LICENSE file. * * Use of this software is strictly AT YOUR OWN RISK!!! * If something bad happens you do not have permission to come crying to me. * (that goes for your lawyer as well) * */ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.Serializable; public class Main { /** * This method takes the given serializable arguments, serializes them into a byte[] and * passes it back to the caller. */ public static final byte[] serialize(Serializable... objects) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); for (Serializable temp : objects) oos.writeObject(temp); oos.close(); return baos.toByteArray(); } catch (IOException ioex) { throw new RuntimeException(ioex); } } }