http请求
来源:互联网 发布:搓碟软件 编辑:程序博客网 时间:2024/06/15 20:12
// 请求返回结果
String result = "";
try
{
// 请求地址
URL url = new URL(postUrl);
URLConnection con = url.openConnection();
con.setDoOutput(true);
con.setRequestProperty("Pragma:", "no-cache");
con.setRequestProperty("Cache-Control", "no-cache");
con.setRequestProperty("Content-Type", "text/html");
OutputStream os = con.getOutputStream();
os.write(xmlInfo.getBytes("UTF-8"));
// os.write(GZIPUtils.compressToByte(xmlInfo));//压缩xml文件
os.flush();
InputStream is = con.getInputStream();
result = IOUtils.toString(is, "UTF-8");
}
catch (MalformedURLException e)
{
logger.error("URL协议、格式或者路径错误!", e);
}
catch (IOException e)
{
logger.error("装载文件--->失败!", e);
}
String result = "";
try
{
// 请求地址
URL url = new URL(postUrl);
URLConnection con = url.openConnection();
con.setDoOutput(true);
con.setRequestProperty("Pragma:", "no-cache");
con.setRequestProperty("Cache-Control", "no-cache");
con.setRequestProperty("Content-Type", "text/html");
OutputStream os = con.getOutputStream();
os.write(xmlInfo.getBytes("UTF-8"));
// os.write(GZIPUtils.compressToByte(xmlInfo));//压缩xml文件
os.flush();
InputStream is = con.getInputStream();
result = IOUtils.toString(is, "UTF-8");
}
catch (MalformedURLException e)
{
logger.error("URL协议、格式或者路径错误!", e);
}
catch (IOException e)
{
logger.error("装载文件--->失败!", e);
}
0 0
- HTTP请求
- http请求
- http请求
- HTTP请求
- HTTP请求
- Http 请求
- http 请求
- HTTP请求
- http请求
- http 请求
- HTTP请求
- HTTP请求
- http请求
- http请求
- http请求
- HTTP请求
- http请求
- http请求
- mantis虚拟主机无法发送邮件
- Intersection of Two Linked Lists
- wordpress新增页面,一周热门,7天最热,一月热门,30天热门文章列表
- eclipse版本号,myeclipse版本号,代号。
- C# 抓取网站验数字验证码
- http请求
- 自动生成文章目录的操作
- Swift语言IOS8开发战记10.Data Model
- OpenGL Shading language学习总结
- 执行力差是谁的责任?
- 路径中 斜杠/和反斜杠\ 的区别
- 微信公众帐号开发教程第17篇-应用实例之智能翻译
- 一场战役的背后是身体与心灵的较量,做Winner!
- UML基础详解