Java HttpURLConnection getResponseCodeThe getResponseCode is a method of Java HttpURLConnection class. This method is used to get the status code from the HTTP response message. For example, if the status line is HTTP/1.0 200 OK Then it will return 200, or if the status line is HTTP/1.0 401 unauthorized, then it will return 401. These method returns -1 if the response from HTTP is not valid. SyntaxReturnsIt returns the status code of HTTP or -1 ThrowsIOException - It throws this exception if an error occurs while connecting the server. Example 1Test it NowOutput: https://www.mysql.com Connection Response Code : 200 Connection Disconnect... Example 2Test it NowOutput: https://www.Facebook.com Connection Response Code : 203 200 https://www.javatpoint.com Connection Response Code : 303 200 Connection Disconnect...
Next TopicJava HttpURLConnection class
|