http代理服务器
我写的一个简单代码出现了以下的错误提示,是怎么回事啊import * ;
import * ;
public class ProxyTest{
public static void main(String args[])throws Exception{
Proxy proxy = null ;
proxy = new Proxy(Proxy.Type.HTTP,new InetSocketAddress("127.0.0.1",8888)); // 实例化本地代理对象,端口为8888
URL url = new URL("http://www.);
HttpURLConnection action = (HttpURLConnection)url.openConnection(proxy); //使用代理打开网页
InputStream in = action.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(in,"UTF-8"));
StringBuilder sb = new StringBuilder();
String lin = System.getProperty("line.separator") ;
for(String temp = br.readLine() ; temp!=null;temp = br.readLine() ){
sb.append(temp+lin);
}
br.close();
in.close();
System.out.println(sb);
}
}
Exception in thread "main" Connection refused: connect
at (Native Method)
at (DualStackPlainSocketImpl.java:79)
at (AbstractPlainSocketImpl.java:339)
at (AbstractPlainSocketImpl.java:200)
at (AbstractPlainSocketImpl.java:182)
at (PlainSocketImpl.java:172)
at (Socket.java:579)
at (Socket.java:528)
at (NetworkClient.java:180)
at (HttpClient.java:432)
at (HttpClient.java:484)
at (HttpClient.java:482)
at java.security.AccessController.doPrivileged(Native Method)
at (HttpClient.java:481)
at (HttpClient.java:522)
at (HttpClient.java:211)
at (HttpClient.java:308)
at (HttpClient.java:326)
at (HttpURLConnection.java:996)
at (HttpURLConnection.java:975)
at (HttpURLConnection.java:850)
at (HttpURLConnection.java:1300)
at ProxyTest.main(ProxyTest.java:12)