URLConnection 已连接 getter

URLConnection connected getter

我正在检查 URLConnection class 的文档,但找不到 connected 字段的 getter/setter .虽然有 getDoInput() ,但没有 isConnected()。所以我想知道是否有方法或其他方法来检查这个。

如果已经有连接,您可以简单地调用 connect() 没有任何反应。

参见connect方法的文档:

If the connect method is called when the connection has already been opened (indicated by the connected field having the value true), the call is ignored.