[导入]hostConfiguration


作者: ecsun  链接: http://papalong.javaeye.com/blog/281088  发表时间: 2008年11月27日

声明:本文系JavaEye网站发布的原创博客文章,未经作者书面许可,严禁任何网站转载本文,否则必将追究法律责任!

HostConfiguration hostConfiguration = new HostConfiguration();
byte b[] = new byte[4];
b
[0] = new Integer(192).byteValue();
b
[1] = new Integer(168).byteValue();
b
[2] = new Integer(1).byteValue();
b
[3] = new Integer(11).byteValue();

hostConfiguration
.setLocalAddress(InetAddress.getByAddress(b));

HttpClient client = new HttpClient();
client
.setHostConfiguration(hostConfiguration);
GetMethod method = new GetMethod("http://remoteserver/");
method
.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
   
new DefaultHttpMethodRetryHandler(3, false));
int statusCode = client.executeMethod(method);

if (statusCode != HttpStatus.SC_OK) {
   
System.err.println("Method failed: " + method.getStatusLine());
}

byte[] responseBody = method.getResponseBody();
System.out.println(new String(responseBody));");



已有 0 人发表留言,猛击->>这里<<-参与讨论


JavaEye推荐




文章来源: http://papalong.javaeye.com/blog/281088

转载于:https://www.cnblogs.com/bubua/archive/2008/12/08/1350755.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值