zoukankan      html  css  js  c++  java
  • 以POST方式发送

    URL url = null;  

            String inputLine = null;  

            HttpURLConnection httpurlconnection = null;  

            try {  

            //取上级电警平台的url

                url = new URL(ConfigManager.getInstance().getConfigItem("urlDJ", ""));  

                httpurlconnection = (HttpURLConnection) url.openConnection();  

                httpurlconnection.setRequestProperty("Content-Type","application/json; charset=UTF-8");

                httpurlconnection.setRequestMethod("POST");  

                httpurlconnection.setConnectTimeout(500000);

                httpurlconnection.setDoOutput(true);  

                httpurlconnection.setDoInput(true);  

                httpurlconnection.setUseCaches(false);  

                httpurlconnection.getOutputStream().write(json.toString().getBytes());  

                httpurlconnection.getOutputStream().flush();  

                httpurlconnection.getOutputStream().close();  

    //            int code = httpurlconnection.getResponseCode();  

                inputLine = readContents(httpurlconnection);  

            } catch (Exception e) {  

                e.printStackTrace();  

            } finally {  

                if (httpurlconnection != null)  

                    httpurlconnection.disconnect();  

            }  

            InterfaceLogger.info("调用上级电警平台获取设备状态接口的返回值inputLine:" + inputLine);

            return inputLine;

     

  • 相关阅读:
    C#使用HttpWebRequest和HttpWebResponse上传文件示例
    c#深拷贝和浅拷贝的区别
    C#redis缓存应用
    如何设计一个高并发系统?
    第2章 关系数据库(重点) | 数据库知识点整理
    第1章 绪论 | 数据库知识点整理
    基于套接字的班级聊天群设计
    两数交换的三种方法(C/C++)
    关于知识图谱的思考
    如何找出唯一成对的数(C/C++)
  • 原文地址:https://www.cnblogs.com/7q4w1e/p/9592395.html
Copyright © 2011-2022 走看看