代码: IP和账号密码我换掉了
System.setProperty("http.proxyHost", "00.00.00.00");
System.setProperty("http.proxyPort", "62648");
URL url = new URL("http://www.juneyaoair.com/");
URLConnection uc = url.openConnection();
String encoded = new String
(Base64.decodeBase64(new String("xxxx:lpwd").getBytes()));
uc.setRequestProperty("Proxy-Authorization", "Basic " + encoded);
uc.connect();
InputStream instream = uc.getInputStream();
StringBuilder sb = new StringBuilder();
int l;
byte[] tmp = new byte[2048];
while ((l = instream.read(tmp)) != -1) {
sb.append(new String(tmp));
}
System.out.println(sb.toString());
报错信息为:
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 407 for URL: http://www.juneyaoair.com/
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1625)
at proxy.Demo2.main(Demo2.java:52)