java使用HTTP代理连接总是能连接的问题
程序代码:
public static void main(String[] argv) throws Exception { byte[] b = new byte[1]; Properties systemSettings = System.getProperties(); systemSettings.put("http.proxyHost", "23.32.22.83"); systemSettings.put("http.proxyPort", "915"); systemSettings.put("proxySet","true"); URL u = new URL("http://www.); HttpURLConnection con = (HttpURLConnection) u.openConnection(); BASE64Encoder encoder = new BASE64Encoder(); String encodedUserPwd = encoder.encode(" : ".getBytes()); con.setRequestProperty("Proxy-Authorization", "Basic " + encodedUserPwd); DataInputStream di = new DataInputStream(con.getInputStream()); while (-1 != di.read(b, 0, 1)) { System.out.print(new String(b)); } System.out.println("\r\nEND:"); }注意:程序中的IP及端口号都是不无效的,
但我郁闷的是这样的程序也能获取到URL返回的数据!
高手们,帮帮忙,看看到底是什么问题...