HttpURLConnection施用代理服务器

HttpURLConnection使用代理服务器Authenticator.setDefault(new SimpleAuthenticator(username,password))

HttpURLConnection使用代理服务器

Authenticator.setDefault(new SimpleAuthenticator(username,password));
Properties systemProperties = System.getProperties();
systemProperties.setProperty("http.proxyHost",proxy);
systemProperties.setProperty("http.proxyPort",port);
HttpURLConnection connection = (HttpURLConnection)server.openConnection();
connection.connect();