[英]How to unset Socks Proxy
我可以通过以下代码设置socks代理服务器:
System.getProperties().setProperty("socksProxySet", "true");
System.getProperties().setProperty("socksProxyHost", address);
System.getProperties().setProperty("socksProxyPort", port);
Accordind http://docs.oracle.com/javase/6/docs/technotes/guides/net/proxies.html ,我可以取消设置HTTP,HTTPS和FTP代理,如下所示:
System.setProperty("http.proxyHost", null);
问题:我也可以取消设置袜子代理吗?
通过做:
System.getProperties().setProperty("socksProxyHost", null);
我什么都没有,只有NullPointerException ......
泰
采用:
System.clearProperty("http.proxySet");
System.clearProperty("http.proxyHost");
System.clearProperty("http.proxyPort");
这将清除代理设置。
您可能还需要清除socksProxyPort
。
socksProxySet
是虚构的,什么都不做; ditto httpProxySet
, http.proxySet
, https.proxySet
等,尽管它在几本书中https.proxySet
所说。
但是,如果你必须使用然后不使用代理,那么你应该真正使用java.net.Proxy
这种事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.