Monday, 9 September 2013

Using socks 4/5 proxy in java?

Using socks 4/5 proxy in java?

Proxy proxy = new Proxy(Proxy.Type.HTTP, new
InetSocketAddress(Action.proxies.get(1), 3128));
try{
url = new URL(formattedURL);
connection = url.openStream();
BufferedReader br = new BufferedReader(new InputStreamReader(
connection));
String line = br.readLine();
while(line !=null){
response.append(line.replace("<br/>","\n").replace("<p>", "\n"));
line = br.readLine();
}
connection.close();
} catch(final Exception e) {
e.printStackTrace();
}
As you can see, I've created an object at the top which gets a proxy from
the hashmap I added data into.
How do I use the proxy so that when the connection is made with
url.openStream() it uses the proxy?

No comments:

Post a Comment