URLConnection getHeaderField Example

URLConnection class getHeaderField example. This example shows you how to use getHeaderField method.


URLConnection class getHeaderField example. public String getHeaderField(String name) Returns the value of the named header field. If called on a connection that sets the same header multiple times with possibly different values, only the last value is returned.

Here is the code
/*
 * @ # GetHeaderField1.java
 * A class repersenting use to GetHeaderField 
 * method of URLConnection class in java.net package
 * version 23 June 2008
 * author Rose India 
 */

import java.net.*;

public class GetHeaderField1 {

    public static void main(String args[]) throws Exception {
        SocketAddress socketAddress =
                new InetSocketAddress("192.168.10.80"9090);
        Proxy proxy = new Proxy(Proxy.Type.HTTP, socketAddress);
        URL url = new URL("http://roseindia.net");
        URLConnection connection = url.openConnection(proxy);

        System.out.println("Header Field " +
                connection.getHeaderField("Description"));
    }
}

Output
Header Field null

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

HOME | COPYRIGHT | CONTACT US