import java.io.*;

public class Serial {
  private static long serialVersionUID = 33825L;

  public static void main( String[] args ) {
    final String s = "1234567890";

    try {
      // Serialize to a file
      ObjectOutput out = new ObjectOutputStream(
		      new FileOutputStream( "Serial.out" )
	      );
      out.writeObject( s );
      out.close();
  
      // Serialize to a byte array
      ByteArrayOutputStream bos = new ByteArrayOutputStream() ;
      out = new ObjectOutputStream( bos ) ;
      out.writeObject( s );
      out.close();
  
      // Get the bytes of the serialized object
      byte[] buf = bos.toByteArray();

      for( int i = 0; i < buf.length; i++ ) {
	// System.out.println( i + ": " + buf[i] );
	System.out.println( i + ": 0x" + Integer.toString( ( buf[i] & 0xff ) + 0x100, 16 /* radix */ ).substring( 1 ) );
      }
    } catch( Exception e ) {
      System.err.println( e );
    }
  } // public static void main( String[] args )
} // public class Serial implements Serializable

/************************ EOF ************************/
