Java HttpURLConnection disconnect() Method

The disconnect() is the method of HttpURLConnection class. This method is used to disconnect the server. This method cannot be used to implement for reusing other HttpURLConnection request.

Syntax

Example 1

Test it Now

Output:

status code from HTTP response message : 200
connection disconnected

Example 2

Test it Now

Output:

Date = Tue, 27 Nov 2018 04:06:28 GMT
Connection disconnected
Server = Apache
Connection disconnected
Set-Cookie = JSESSIONID=615EA0EEF0B0C58FFE5D6FB233FCA458; Path=/; Secure; HttpOnly
Connection disconnected
Content-Type = text/html;charset=ISO-8859-1
Connection disconnected
Cache-Control = max-age=2592000
Connection disconnected
Expires = Thu, 27 Dec 2018 04:06:28 GMT
Connection disconnected
Vary = Accept-Encoding,User-Agent
Connection disconnected
Keep-Alive = timeout=5, max=4000
Connection disconnected




Latest Courses