Read from URL java

后端 未结 4 1269
抹茶落季
抹茶落季 2021-01-03 00:57

I\'m trying to read URL in java, and it works as long as the URL is loading in browser.

But if it is just cylcing in the browser and not loading that page when I\'m

4条回答
  •  -上瘾入骨i
    2021-01-03 01:05

    I don't know how u are using the URL class. It would have been better if post a snippet. But here is a way that works for me. See if it helps in your case:

        URL url = new URL(urlPath);
        URLConnection con = url.openConnection();
        con.setConnectTimeout(connectTimeout);
        con.setReadTimeout(readTimeout);
        InputStream in = con.getInputStream();
    

提交回复
热议问题