Sunday, November 21, 2010

How to use Proxy in java

 Proxy proxy =null;  
 URL url;  
 String decodedXml=null;  
 DataInputStream inStream=null;  
 proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(ProxyAddress, ProxyPort));  
 // Above line creates proxy with given address and port
 url = new URL(getUrl);  // you need to give your url here
 URLConnection conn = url.openConnection(proxy);// it creates a connection using proxy
 String flag;  
 inStream = new DataInputStream(conn.getInputStream());  

No comments: