ProxySelector.getDefault(): This method is available in the java.net.ProxySelector class of Java.
Syntax:
ProxySelector java.net.ProxySelector.getDefault()
This method gets the system-wide proxy selector.
Parameters: NA
Returns: the system-wide ProxySelector.
Throws:
1. SecurityException - If a security manager has been installed and it denies NetPermission("getProxySelector").
Approach
Java
package com.ProxySelector;import java.net.ProxySelector;public class ProxySelectorgetDefault {public static void main(String[] args) {ProxySelector proxySelector =ProxySelector.getDefault();System.out.println(proxySelector);}}
Output:
sun.net.spi.DefaultProxySelector@5d22bbb7
Some other methods of ProxySelector class
connectFailed(URI, SocketAddress, IOException): This method is called to indicate that a connection could not be established to a proxy/socks server.
getDefault(): This method gets the system-wide proxy selector.
ProxySelector.of(InetSocketAddress): This method returns a ProxySelector which uses the given proxy address for all HTTP and HTTPS requests. If the proxy is null then proxying is disabled.
select(URI): This method selects all the applicable proxies based on the protocol to access the resource with and a destination address to access the resource at.
ProxySelector.setDefault(ProxySelector): This method sets (or unsets) the system-wide proxy selector.
No comments:
Post a Comment