Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-16-2007, 06:32 PM
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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-07-2007, 06:54 AM
Member
 
Join Date: Jul 2007
Posts: 39
coco is on a distinguished road
First...let me state the obvious...there is more than one way to do this. Of course..it all depends on what you want to achieve in the end.

First solution.
You can use threads. where you initiate the thread to open a web page...and then interrupt it (kill it) when a specified time has elapsed.

Second Solution.
You can make use of javax.swing.Timer, and schedule a delay before stopping the execution.

I am sure that there are other ways to do this.
Greetings.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
i need help in http process sureshjava New To Java 0 01-29-2008 06:56 AM
How to get variable values at runtime in another process murali_java Advanced Java 0 11-02-2007 10:03 AM
Business Process Visual ARCHITECT 2.1 levent Java Announcements 0 08-04-2007 09:49 PM
Linux process from java Ed New To Java 2 07-04-2007 07:03 AM
Business Process Visual ARCHITECT 2.0 SP2 levent Java Announcements 0 05-15-2007 07:51 AM


All times are GMT +3. The time now is 04:55 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org