Listing C


import java.net.*;

import java.io.*;
 

public void writeToURL()

{

   try

   {

     URL url = new URL("http://www.mycompany.com");

      URLConnection connection = url.openConnection();

      connection.setDoOutput(true);

      OutputStream outStream = connection.getOutputStream();

      ObjectOutputStream objectStream = new ObjectOutputStream(outStream);

      objectStream.writeInt(54367);

      objectStream.writeObject("Hello there");

      objectStream.writeObject(new Date());

      objectStream.flush();

   }

   catch (Exception e)

   {

      System.out.println(e.toString());

   }

}