Reputation: 638
I am trying to read data from the given web page using Java.
public class WebpageReader {
public static void main(String[] args) throws IOException {
String line = null, response;
URL url = new URL("http://www.google.co.in/");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
BufferedReader rd = new BufferedReader(new InputStreamReader(conn
.getInputStream()));
while (rd.readLine() != null) {
line += rd.readLine();
}
System.out.println(line);
}
}
But I'm getting the connection refused exception. What might be correct way to get the date from webpage?
Upvotes: 3
Views: 12843
Reputation: 104178
You are probably behind a proxy that doesn't allow you to connect to a web resource through a java application. You can configure a proxy in the java options. In Windows you can do that from the Control Panel.
Upvotes: 1