URLConnection getHeaderFieldInt Example

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


URLConnection class getHeaderFieldInt example. public int getHeaderFieldInt(String name, int Default) Returns the value of the named field parsed as a number. This form of getHeaderField exists because some connection types (e.g., http-ng) have pre-parsed headers. Classes for that connection type can override this method and short-circuit the parsing.

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

import java.net.*;

public class GetHeaderFieldInt {

    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://google.com");
        URLConnection connection = url.openConnection(proxy);

        System.out.println("Header Field Int " +
                connection.getHeaderFieldInt("Expires"0));
    }
}

Output
Header Field Int -1

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

HOME | COPYRIGHT | CONTACT US