Created
June 23, 2018 06:18
-
-
Save sarbajitc/2ad1e1e974e9bd5176de1ca3a2581743 to your computer and use it in GitHub Desktop.
Proxy selector java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.w3schools.client; | |
import java.io.IOException; | |
import java.net.InetSocketAddress; | |
import java.net.*; | |
import java.util.*; | |
public class MyProxySelector extends ProxySelector { | |
@Override | |
public List<proxy> select(URI uri) | |
{ | |
// Setting up a new ProxySelector implementation | |
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("mywebproxy.com", 8080)); | |
ArrayList<proxy> list = new ArrayList<proxy>(); | |
list.add(proxy); | |
return list; | |
} | |
@Override | |
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { | |
System.err.println("Connection to " + uri + " failed."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment