I'm trying to understand how the ProxySelector class works. My current code looks like this:
URI uri = new URI("http://google.com");
proxySelector.select(uri);
I understand that when calling proxySelector.select(uri);
this is suppose to return a list of proxies for the respective URI. But I don't see how to set the proxy for each URI.
I know I could set the default proxy using the setDefault()
method but as far as I understand this will set the system wide proxy, not the proxy for a specific URI
.
I might be missing some basic point here but how do I set one proxy for url A (such as http://google.com) and a different proxy for url B (such as http://ebay.com) and then have the system automatically select the correct proxy each time it connects to the corresponding url?