1

HttpURLConnection如果在完成之前超时,有什么方法可以触发事件?

4

2 回答 2

2

There is no built-in timeout for this. What I do is to use a different thread and interrupt the thread after the timeout.

It's easier to use FutureTask for this. See my answer to this question,

java native Process timeout

于 2010-05-30T13:17:39.207 回答
1
URLConnection.setConnectTimeout()
URLConnection.setReadTimeout()

@从 1.5 开始

于 2010-05-31T05:48:11.883 回答