Code example for Proxy

0
 
public class ProxyTester { 
	static final List<Proxy> PROXIES = new LinkedList<Proxy>();
	static { 
		try { 
			PROXIES.add(new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(InetAddress.getLocalHost(), 80)));
			PROXIES.add(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(InetAddress.getLocalHost(), 80)));
		} catch (UnknownHostException e) {}
	} 
 
	public static void main(String[] args) throws UnknownHostException, IOException {
		ProxySelector.setDefault(new ProxySelector() {
			@Override 
			public List<Proxy> select(URI uri) {
				return PROXIES;
			} 
 
			@Override 
			public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
				 
			}