URLConnection getRequestPropertys Example
URLConnection class getRequestPropertys example. This example shows you how to use getRequestPropertys method.
URLConnection class getRequestPropertys example. public Map getRequestProperties() Returns an unmodifiable Map of general request properties for this connection. The Map keys are Strings that represent the request-header field names.
Here is the code
/*
* @ # GetRequestProperties.java
* A class repersenting use to GetRequestProperties method
* of URL class in java.net package
* version 24 June 2008
* author Rose India
*/
import java.net.*;
import java.util.*;
public class GetRequestProperties {
public static void main(String args[]) throws Exception {
SocketAddress address = new InetSocketAddress("192.168.10.80", 9090);
Proxy proxy = new Proxy(Proxy.Type.HTTP, address);
URL url = new URL("http://yahoo.com");
URLConnection connection = url.openConnection(proxy);
Map map = connection.getRequestProperties();
Set set = map.entrySet();
Iterator iterator = set.iterator();
System.out.println("request properties "+iterator.hasNext());
while (iterator.hasNext()) {
System.out.println(iterator.next());
}
}
} |
|