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() method, I get the same result if I don't use it.
Why (or when) do I need to use it?
Operations that depend on being connected, like getContentLength, will implicitly perform the connection, if necessary.
In other words, if you don't call connect() but you call some other method which needs to be connected, that other method will call connect() itself if it isn't already connected. Does that clarify things for you?