importjava.io.*;importjava.net.*;importjava.util.Date;classURLConnectionDemo{publicstaticvoidmain(String[]args)throwsMalformedURLException{try{URLurl=newURL("http://www.internic.net");URLConnectionurlconn=url.openConnection();System.out.println("Content Length : "+urlconn.getContentLength());// Returns -1 if unavailable.longd=urlconn.getDate();// Returns 0 if unavailableSystem.out.println("Date : "+d);System.out.println("Content Type : "+urlconn.getContentType());// get expiration dated=urlconn.getExpiration();if(d==0)System.out.println("No expiration information.");elseSystem.out.println("Expires: "+newDate(d));// get last-modified dated=urlconn.getLastModified();if(d==0)System.out.println("No last-modified information.");elseSystem.out.println("Last-Modified: "+newDate(d));// get content lengthlonglen=urlconn.getContentLengthLong();if(len==-1)System.out.println("Content length unavailable.");elseSystem.out.println("Content-Length: "+len);InputStreamis=urlconn.getInputStream();// Returns an InputStream that is linked to the resource. This// stream can be used to obtain the content of the resource. It// throws IOException.intinputChar;while((inputChar=is.read())!=-1){System.out.print((char)inputChar);}is.close();}catch(IOExceptionexc){exc.printStackTrace();}}}