In one of the
Java tutorials there's an example (see below) of how to connect to a URL and read its contents.
Usually this code works, but in my project, it does not!!! The URL.openStream() throws an Exception. What could be the problem? Could there be some network restrictions on the location where I'm working?
Cheers,
-Ruud.
import java.net.*;
import java.io.*;
public class URLReader {
public static void main(
String[] args) throws Exception {
URL yahoo = new URL("http://www.interpolis.nl/");
BufferedReader in = new BufferedReader(
new InputStreamReader(
yahoo.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}