search

Home  >  Q&A  >  body text

java - 如何判断URLConnection超时,自动重连?

我想通过URLConnection下载网页源码? 因为开很多个线程下载,所以会出现超时的情况。
请问要如何处理才能保证一定下载成功呢?

黄舟黄舟2811 days ago739

reply all(1)I'll reply

  • 黄舟

    黄舟2017-04-18 09:32:23

    Manually access a website that does not exist and let it throw a timeout exception, and then catch the exception and judge it. If it is a timeout exception when running again, re-initiate the request.

    reply
    0
  • Cancelreply