My program downloads webpages.
It works fine as long as the url is valid.
If the url is not valid it waits forever.
How can I set a time out on the loading process?
try {
URL pageUrl = new URL(currentUrl);
BufferedReader reader = new BufferedReader(
new InputStreamReader(pageUrl.openStream() ) );
String line;
StringBuffer pageBuffer = new StringBuffer();
while ( (line = reader.readLine() ) != null ) {
pageBuffer.append( line );
}
String fetchedPage = pageBuffer.toString();
}
catch (Exception e) {
}
Thanks