Results 1 to 2 of 2
- 07-16-2007, 04:32 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 26
- Rep Power
- 0
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?
ThanksJava 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) { }
- 08-07-2007, 04:54 AM #2
Member
- Join Date
- Jul 2007
- Posts
- 39
- Rep Power
- 0
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.
Similar Threads
-
i need help in http process
By sureshjava in forum New To JavaReplies: 0Last Post: 01-29-2008, 04:56 AM -
How to get variable values at runtime in another process
By murali_java in forum Advanced JavaReplies: 0Last Post: 11-02-2007, 08:03 AM -
Business Process Visual ARCHITECT 2.1
By levent in forum Java SoftwareReplies: 0Last Post: 08-04-2007, 07:49 PM -
Linux process from java
By Ed in forum New To JavaReplies: 2Last Post: 07-04-2007, 05:03 AM -
Business Process Visual ARCHITECT 2.0 SP2
By levent in forum Java SoftwareReplies: 0Last Post: 05-15-2007, 05:51 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks