private String indexPage(URL currentPage) throws IOException {
String content = "";
is = currentPage.openStream();
content = new Scanner( is ).useDelimiter( "\\Z" ).next();
return content;
}
This is my function with which I'm currently crawling webpages. The function that a problem is:
content = new Scanner( is ).useDelimiter( "\\Z" ).next();
If the webpage doesn't answer or takes a long time to answer, my thread just hangs at the above line. What's the easiest way to abort this function, if it takes longer than 5 seconds to load fully load that stream?
Thanks in advance!