- Construct a URL object from a URL starting with the
http or ftp prefix
URL u = new URL("http://java.sun.com/index.html");
- Use the URL's openConnection() method to get
the URLConnection
URLConnection connection = u.openConnection();
- Call the getInputStream method to obtain an input
stream
InputStream in = connection.getInputStream();
- Construct a reader from the stream
BufferedReader in = new BufferedReader(
new InputStreamReader(in));