使用Java中的代理连接到URL [英] Connecting to the url using proxy in java

查看:240
本文介绍了使用Java中的代理连接到URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我写了以下访问网址..

没有代理:

 字符串 strUrl1 = " ;
            URL url =  URL(strUrl1.toString());
            URLConnection conn = url.openConnection(); 


它的连接..

但是现在我正在使用代理..
现在也直接连接.


解决方案

使用以下选项:

java -Dhttp.proxyHost = myproxyhost MyClass

http://edn.embarcadero.com/article/29783 [

Hi,

i written the following access the url..

with out proxy:

String strUrl1 = "http://www.google.com";
            URL url = new URL(strUrl1.toString());
            URLConnection conn = url.openConnection(); 


its connecting..

but now i am using the proxy..
now also it directly connecting.


how?

解决方案

Use the following option:

java -Dhttp.proxyHost=myproxyhost MyClass

Took it from
http://edn.embarcadero.com/article/29783[^], which is the first link for searching Google with "using a proxy server in java".


这篇关于使用Java中的代理连接到URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆