public static byte[] serializeJdk(Object obj) throws IOException {
  ByteArrayOutputStream byteOut=null;
  ObjectOutputStream objOut=null;
  try {
    byteOut=new ByteArrayOutputStream(512);
    objOut=new ObjectOutputStream(byteOut);
    objOut.writeObject(obj);
    objOut.flush();
    return byteOut.toByteArray();
  }
  finally {
    close(objOut);
    close(byteOut);
  }
}

public static byte [ ] serializeJdk ( Object obj ) throws IOException { ByteArrayOutputStream byteOut = null ; ObjectOutputStream objOut = null ; try { byteOut = new ByteArrayOutputStream ( 512 ) ; objOut = new ObjectOutputStream ( byteOut ) ; objOut . writeObject ( obj ) ; objOut . flush ( ) ; return byteOut . toByteArray ( ) ; } finally { close ( objOut ) ; close ( byteOut ) ; } }
serializes a given object into byte array .
