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();
}
如您所见,我在顶部创建了一个对象,该对象从我添加数据的 HashMap 中获取代理。
如何使用代理,以便在与url.openStream()
它建立连接时使用代理?