zoukankan      html  css  js  c++  java
  • Android 开发工具类 30_sendXML

    String xml = "<?xml version="1.0" encoding="UTF-8"?>

    <persons><person id="23"><name>hello</name><age>30

    </age></person></persons>";

     1 private static boolean sendXML(String path, String xml) throws Exception{
     2         //  
     3         byte[] data = xml.getBytes();
     4         
     5         HttpURLConnection conn = (HttpURLConnection) new URL(path).openConnection();
     6         conn.setConnectTimeout(5000);
     7         conn.setRequestMethod("POST");
     8         conn.setDoOutput(true);//允许对外传输数据
     9         conn.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
    10         conn.setRequestProperty("Content-Length", String.valueOf(data.length));
    11         
    12         OutputStream outStream = conn.getOutputStream();
    13         outStream.write(data);
    14         outStream.flush();
    15         outStream.close();
    16         
    17         if(conn.getResponseCode() == 200){
    18             return true;
    19         }
    20         return false;
    21     }
  • 相关阅读:
    spark shuffle 机制
    hive explain 源码分析
    前端jQurey
    js-dom操作
    前端JS
    前端CSS
    Redis和MongoDB区别
    MySQL数据库备份
    MySQL索引
    python连接mysql服务端
  • 原文地址:https://www.cnblogs.com/renzimu/p/4540888.html
Copyright © 2011-2022 走看看