Java URLConnection - When do I need to use the connect() method?

后端 未结 2 422
粉色の甜心
粉色の甜心 2020-12-06 03:58

I have a problem to understand the meaning of the connect() method in the URLConnection class. In the following code, if I use the connect()<

2条回答
  •  猫巷女王i
    2020-12-06 04:49

    You are not always required to explicitly call the connect method to initiate the connection.

    Operations that depend on being connected, like getInputStream, getOutputStream, etc, will implicitly perform the connection, if necessary.

    Here's the oracle doc link

提交回复
热议问题