try
{
// read sequence and iterator from file
ObjectInputStream s = new ObjectInputStream( new FileInputStream( "Serial2.ser" ) );
DList names = (DList)s.readObject();
ForwardIterator wolverine = (ForwardIterator)s.readObject();
ForwardIterator hulk = (ForwardIterator)s.readObject();
// check the iterators
if ( wolverine.equals( names.end() ) )
System.out.println( "Don't know who Wolverine is" );
else
System.out.println( "Wolverine is also known as " + wolverine.get() );
if ( hulk.equals( names.end() ) )
System.out.println( "Don't know who the Hulk is" );
else
System.out.println( "Hulk is also known as " + hulk.get() );
}
catch ( IOException e1 )
{
System.out.println( "caught: " + e1 );
}
catch ( ClassNotFoundException e2 )
{
System.out.println( "caught: " + e2 );
}