View Single Post
  #1 (permalink)  
Old 07-16-2007, 06:32 PM
paul paul is offline
Member
 
Join Date: Jul 2007
Posts: 26
paul is on a distinguished road
How can I set a time out on the loading process
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?

Code:
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
Reply With Quote
Sponsored Links