Some of the Proxy constants.
1. Proxy.NO_PROXY
Proxy java.net.Proxy.NO_PROXY
A proxy setting that represents a DIRECT connection, basically telling the protocol handler not to use any proxying.Used, for instance, to create sockets bypassing any other global proxy settings (like SOCKS):
Socket s = new Socket(Proxy.NO_PROXY);
2. Type.DIRECT
java.net.Proxy.Type.DIRECT
Represents a direct connection, or the absence of a proxy.
3. Type.HTTP
java.net.Proxy.Type.HTTP
Represents proxy for high-level protocols such as HTTP or FTP.
4. Type.SOCKS
java.net.Proxy.Type.SOCKS
Represents a SOCKS (V4 or V5) proxy.
5. Type.valueOf(String name)
Type java.net.Proxy.Type.valueOf(String name)
Represents proxy with the given name.
Parameters: One parameter is required for this method.
name: name of the proxy.
Approach
Java
package com.Proxy;import java.net.Proxy;public class ProxyConstants {public static void main(String[] args) {System.out.println(Proxy.NO_PROXY);System.out.println(Proxy.Type.DIRECT);System.out.println(Proxy.Type.HTTP);System.out.println(Proxy.Type.SOCKS);String name = "DIRECT";System.out.println(Proxy.Type.valueOf(name));}}
Output:
DIRECT DIRECT HTTP SOCKS DIRECT
Some other methods of Proxy class
Proxy(Type, SocketAddress): This method creates an entry representing a PROXY connection.
address(): This method returns the socket address of the proxy, or null if it's a direct connection.
Proxy Constants: Some of the Proxy constants like Proxy.NO_PROXY, Type.DIRECT, etc.
equals(Object): This method compares this object against the specified object.
hashCode(): This method returns a hashcode for this Proxy.
toString(): This method constructs a string representation of this Proxy. This String is constructed by calling toString() on its type and concatenating " @ " and the toString() results from its address if its type is not DIRECT.
type(): This method returns the proxy type.
No comments:
Post a Comment