我正在检查 URLConnection 的文档类,我无法为 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.
关于java - URLConnection 连接的 getter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32119742/