HttpURLConnection GetHeaderField() Example

Returns the value for the nth header field.


HttpURLConnectionclass GetHeaderField() method example. This example shows you how to use GetHeaderField() method.This method Returns the value for the nth header field.

Here is the code:-
/* 
 * @Program that Returns the value of the nth header field.
 * GetHeaderField.java 
 * Author:-RoseIndia Team
 * Date:-25-Jun-2008
 */

import java.io.*;
import java.net.*;

public class GetHeaderField {

    public static void main(String[] argsthrows Exception {
        URL url = new URL("http://192.168.10.211:8080");
        HttpURLConnection connection = 
                (HttpURLConnectionurl.openConnection();
        System.out.println(connection.getHeaderFieldKey(3));
        // //Returns the value of the nth header field.
        System.out.println(connection.getHeaderField(3));
    }
}

Output of the program:-
 Last-Modified
Mon, 28 Jan 2008 22:39:35 GMT

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US