How can I set a timeout against a BufferedReader based upon a URLConnection in Java?

前端 未结 5 1206
面向向阳花
面向向阳花 2020-12-19 02:25

I want to read the contents of a URL but don\'t want to \"hang\" if the URL is unresponsive. I\'ve created a BufferedReader using the URL...



        
5条回答
  •  一个人的身影
    2020-12-19 02:57

    For Java 1.4, you may use SimpleHttpConnectionManager.getConnectionWithTimeout(hostConf,CONNECTION_TIMEOUT) from Apache

提交回复
热议问题