I am trying to read data from a given webpage 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);
}
}
code> But I get an exception rejection message. What could be the right way to get a date from a web page?
source
share