import java.io.*;
import java.net.*;
import java.util.Date;

class URLConnections
{
    public static void main(String args[]) throws Exception 
    {
        int character;
        
        URL url = new URL("http://www.yourserver.com/user/index.html");
        URLConnection urlconnection = url.openConnection();

        System.out.println("Content type: " + 
            urlconnection.getContentType());
        System.out.println("Document date: " + 
            new Date(urlconnection.getDate()));
        System.out.println("Last modified: " +
            new Date(urlconnection.getLastModified()));
        System.out.println("Document expires: " + 
            urlconnection.getExpiration());
        
        int contentlength = urlconnection.getContentLength();

        System.out.println("Content length: " + contentlength);

        if (contentlength > 0) {
            InputStream in = urlconnection.getInputStream();

            while ((character = in.read()) != -1) {
                System.out.print((char) character);
            }

            in.close();
        } 
    }
}
