devxlogo

Implementing a Proxy Selector in the Tiger Release of Tiger

Implementing a Proxy Selector in the Tiger Release of Tiger

Use this code to implement a proxy selector class in the Tiger release of Tiger:

import java.net.*;import java.util.*;import java.io.*;public class MyProxySelector extends ProxySelector{  //implement the select method  public List select(URI uri)  {        //the proxy servers list    List proxys=new ArrayList();  if((uri.getHost()).equals("www.yahoo.com"))   {   try{      InetAddress addr=InetAddress.getLocalHost();      InetSocketAddress ISA=new InetSocketAddress(addr,808);      java.net.Proxy proxy=new java.net.Proxy                                java.net.Proxy.Type.HTTP,ISA);      proxys.add(proxy);     }catch(java.net.UnknownHostException e)            {System.out.println(e.getMessage());}    }        else       System.out.println("Unknown address...");        return proxys;      }    //the connectFailed method  public void connectFailed(URI uri, SocketAddress address, IOException ex)  {  System.out.println(uri.getHost());  System.out.println("Fatal error...");  } }
See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist