/**
 * Arrange to close a stream when the JVM terminates.
 * @param dos DataOutputStream to close.
 */
void closeOnExit ( DataOutputStream dos )
    {
    Runtime.getRuntime().addShutdownHook( new Thread()
                                              {
                                              public void run()
                                                  {
                                                  try
                                                      {
                                                      dos.close();
                                                      }
                                                  catch ( IOException e )
                                                      {
                                                      err.println( "Cannot close stream" );
                                                      }
                                                  }
                                              }