//*
195.*发送获取请求
196.*/
publicstaticvoidget (
closeablehttpclienthttpclient=http clients.create default (;
try{
创建http获取。
HttpGethttpget=newHttpGet ('
http://211.156.193.14033608002/cotrackapi/API/track/mail/1104389559880 ' )
HTPget.setheader(authenticate,) sdgszzswsgp_xiangmu123456;
HTPget.setheader('version ',' ems_track_cn_1.0 ' );
HTP get.setheader (accept-charset ),) ISO8859-1 );
//system.out.println (executing request ' http get.geturi ) );
执行//get请求。
closeablehttpresponseresponse=http client.execute (http get );
try{
//获取响应实体
httpentityentity=response.get entity (;
//system.out.print ln----------------------;
//打印响应状态
//system.out.println (response.get statusline () );
if (实体!=null ) {
//打印响应内容的长度
//system.out.println (response contentlength : (entity.get contentlength ) );
//打印响应内容
stringjsmc=entity utils.tostring (entity;
system.out.println (response content : ) jsmc );
stringjsmc1=new string (jsmc.getbytes (iso-8859-1 ),);
system.out.print ln---------- jsm C1 );
stringjsmc2=new string (jsmc.getbytes (iso-8859-1 ),) utf-8 );
system.out.print ln---------- js mc2 );
//stringjsmc1=new string (jsmc.getbytes (iso-8859-1 ),) GBK )
//system.out.print ln-------------jsm C1 );
}
}finally{
response.close (;
}
} catch (客户端协议封装) {
e .打印任务跟踪(;
}catch(parseexceptione ) {
e .打印任务跟踪(;
}catch(ioexceptione ) {
e .打印任务跟踪(;
}finally{
//断开连接,释放资源
try{
httpclient.close (;
}catch(ioexceptione ) {
e .打印任务跟踪(;
}
}
}
萨瓦迪卡
本文由站长原创或收集,不代表本站立场。 转载时请注明出处。 http://www.SW zhinan.com/post/55.html