I\'m trying to read URL in java, and it works as long as the URL is loading in browser.
But if it is just cylcing in the browser and not loading that page when I\'m
The URL#openStream method is actually just a shortcut for openConnection().getInputStream()
. Here is the code from the URL class:
public final InputStream openStream() throws java.io.IOException {
return openConnection().getInputStream();
}
You can adjust settings in the client code as follows:
URLConnection conn = url.openConnection();
// setting timeouts
conn.setConnectTimeout(connectTimeoutinMilliseconds);
conn.setReadTimeout(readTimeoutinMilliseconds);
InputStream in = conn.getInputStream();
Reference: URLConnection#setReadTimeout, URLConnection#setConnectTimeout
sun.net.client.defaultConnectTimeout
and sun.net.client.defaultReadTimeout
system property to a reasonable value.