读书人

HttpURLConnection设立代理服务器

发布时间: 2012-09-09 09:27:54 作者: rapoo

HttpURLConnection设置代理服务器
1、设置系统数据

System.setProperty("http.proxyHost", "proxy.com");System.setProperty("http.proxyPort", "80");URL url=new URL("http://someserver/somepage");URLConnection uc = url.openConnection ();String encoded = new String      (Base64.base64Encode(new String("username:password").getBytes()));uc.setRequestProperty("Proxy-Authorization", "Basic " + encoded);uc.connect();

读书人网 >编程

热点推荐