Java HttpURLConnection getHeaderField() MethodThe getHeaderField(int n) is the method of HttpURLConnection class. This method is used to get n header field. It returns 0 when it is a special header field, i.e., 0th header field. This method can also be used with the getHeaderFieldKey method to get all the headers of the message. SyntaxParametern - an index, where n>=0. ReturnsIt returns the nth header field, else it returns null. Example 1Test it NowOutput: Header field 0:HTTP/1.1 200 200 Header field 1:Thu, 29 Nov 2018 15:19:27 GMT getFollowRedirects : true connection disconnected Example 2Test it NowOutput: www.mysql.com Header field 0:HTTP/1.1 200 OK Header field 1:Thu, 29 Nov 2018 15:25:37 GMT www.oracle.com Header field 0:HTTP/1.1 200 OK Header field 1:Oracle-HTTP-Server getFollowRedirects : true connection disconnected Next TopicJava HttpURLConnection class |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India