Java HttpURLConnection getResponseMessage

The getResponseMessage is a method of Java HttpURLConnection class. This method is used to get response code from HTTP response message. For example, if the response code from a server is HTTP/1.0 200 OK or HTTP/1.0 404 Not Found, it extracts the string OK and Not Found else returns null if HTTP is not valid.

Syntax

Returns

It returns response message of HTTP or null

Throw

IOException - It throws this exception if an error occurs while connecting the server.

Example 1

Test it Now

Output:

https://www.javatpoint.com
Connection Response Message : 200

Example 2

Test it Now

Output:

https://www.facebook.com
Connection Response Message : OK




Latest Courses