urlTest - System.out.println("Content type: " +

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.net.*; import java.io.*; public class urlTest { public static void main(String[] args) { try { URL url = new URL("http://www.google.com/index.html"); System.out.println("------------------------------"); System.out.println("Host: " + url.getHost()); System.out.println("File: " + url.getPath()); URLConnection connection = url.openConnection(); System.out.println("------------------------------"); System.out.println("Date: " + connection.getDate());
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: System.out.println("Content type: " + connection.getContentType()); System.out.println("Length: " + connection.getContentLength()); System.out.println("------------------------------"); BufferedReader in = new BufferedReader( new InputStreamReader( connection.getInputStream())); String line; while( (line=in.readLine()) != null) { System.out.println(line); } in.close(); } catch(MalformedURLException e){} catch(IOException e){} } }...
View Full Document

This note was uploaded on 07/14/2011 for the course COP 4610L taught by Professor Staff during the Spring '09 term at University of Central Florida.

Ask a homework question - tutors are online