如果HttpURLConnection
在完成之前超时,有什么方法可以触发事件?
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,
URLConnection.setConnectTimeout()
URLConnection.setReadTimeout()
@since 1.5
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.