1、常用代理
a、默认代理:proxyHost;proxyPort;proxyUser;proxyPassword
b、http代理:http.proxyHost;http.proxyPort;http.proxyUser;http.proxyPassword
c、socket代理:socksProxyHost;socksProxyPort;socksProxyUser;socksProxyPassword
d、ftp代理:ftp.proxyHost;ftp.proxyPort;ftp.proxyUser;ftp.proxyPassword
2、程序设置
a、系统属性中设置
Properties props
=
System.getProperties();
props.put(
"
proxySet
"
,
"
true
"
);
//
System.setProperty("proxySet", "true");
props.put(
"
socksProxyHost
"
,{PROXY_HOST});
props.put(
"
socksProxyPort
"
,{PROXY_PORT});
HttpURLConnection.setRequestProperty(
"
Proxy-Authorization
"
,
"
Basic
"
+
Encoder.base64Encode( {PROXY_USER}
+
"
:
"
+
{PROXY_PSWD} ) );
(以socket为例)
b、运行参数中设置
java -DsocksProxyHost={PROXY_HOST} -DsocksProxyPort={PROXY_PORT} *.class
(以socket为例)
posted on 2007-02-25 09:52
Xu Jianxiang 阅读(764)
评论(0) 编辑 收藏 所属分类:
Java Tech