// 请求返回结果
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);
}