public final synchronized byte[] toByteArray(){
  ByteArrayOutputStream baos=null;
  DataOutputStream dos=null;
  try {
    baos=new ByteArrayOutputStream(32768);
    dos=new DataOutputStream(baos);
    game.writeToStream(dos);
    dos.flush();
    return baos.toByteArray();
  }
 catch (  IOException e) {
    return null;
  }
 finally {
    if (dos != null)     try {
      dos.close();
    }
 catch (    IOException ex) {
    }
    if (baos != null)     try {
      baos.close();
    }
 catch (    IOException ex) {
    }
  }
}

public final synchronized byte [ ] toByteArray ( ) { ByteArrayOutputStream baos = null ; DataOutputStream dos = null ; try { baos = new ByteArrayOutputStream ( 32768 ) ; dos = new DataOutputStream ( baos ) ; game . writeToStream ( dos ) ; dos . flush ( ) ; return baos . toByteArray ( ) ; } catch ( IOException e ) { return null ; } finally { if ( dos != null ) try { dos . close ( ) ; } catch ( IOException ex ) { } if ( baos != null ) try { baos . close ( ) ; } catch ( IOException ex ) { } } }
serialize to byte array .
