// Quick example of one way to retrieve a web file's source. Note that // you might want to attach the InputStream object to some kind of buffered // reader object to give yourself more than one-byte-at-a-time control // of the input. import java.io.*; import java.net.*; class HTTPGet { public static void main( String[] args ) { try { URL url = new URL( "http://www.mathcs.carleton.edu/faculty/jondich/cs257/index.html" ); InputStream in = url.openStream(); int ch; while( (ch=in.read()) != -1 ) { System.out.print( (char)(ch) ); } } catch( MalformedURLException e ) { System.err.println( "Bad URL format: " + e.getMessage() ); } catch( IOException e ) { System.err.println( "No such URL: " + e.getMessage() ); } } }