读书人

HttpURLConnection施用代理服务器

发布时间: 2012-12-19 14:13:15 作者: rapoo

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();

读书人网 >编程

热点推荐