java post json的用法
来源:互联网 发布:js恶搞死机 编辑:程序博客网 时间:2024/06/05 05:55
在我用到java post json 请求数据的时候 我遇到了很多麻烦
下面的做法是 请求在android 中的用法
因为我才用的是函数的方法, 记录 希望也能给别人有一点点帮助
public static boolean send_post(String url, final String json) { final String Url = Define.URL + url; new Thread() { @Override public void run() { super.run(); try { URL url = new URL(Url); HttpURLConnection connection = (HttpURLConnection) url .openConnection(); connection.setDoOutput(true); connection.setDoInput(true); connection.setRequestMethod("POST"); connection.setRequestProperty("X-LC-Id", "1PH7yWlIEYLsHJ49p6bfGm64-gzGzoHsz"); connection.setRequestProperty("X-LC-Key", "Ao0WO5c1zgNj23i05zkJUt5s"); connection.setRequestProperty("Content-Type", "application/json"); DataOutputStream dataOutputStream = new DataOutputStream(connection.getOutputStream()); dataOutputStream.write(json.getBytes()); dataOutputStream.flush(); dataOutputStream.close(); connection.connect(); int code = connection.getResponseCode(); Log.i("xjxu", code + ""); StringBuffer stringBuffer = new StringBuffer(); BufferedReader in = new BufferedReader(new InputStreamReader(connection .getInputStream())); String readLine = ""; while ((readLine = in.readLine()) != null) { stringBuffer.append(readLine); } in.close(); Log.i("xjxu",stringBuffer.toString()); } catch (IOException e) { e.printStackTrace(); } } }.start(); return true; }
0 0
- java post json的用法
- java post json 请求
- java http post json
- java http post json
- java post json 数据包
- java post json
- Java Json Post 请求
- java发送JSON格式的http通讯的post请求
- java通过post上传json
- 关于java的POST和GET(org.json.jar)
- java 读取 ajax post 到后台的Json数据
- java发送http的get、post请求 登录返JSON
- Java解析POST提交的json数据工具类
- Java发送HTTP的get,post请求(JSON)
- Post的简单用法
- okhttp的post用法
- Volley的Post用法
- HttPClient的POST用法
- FCK编辑器在项目中的引入
- FastJson toString过滤指定的对象属性
- 【图像特征提取9】OpenCv中SURF源码的分析二
- 输出链表的倒数第k个节点
- 数据库三范式(NF)
- java post json的用法
- Spring Bean的生命周期
- 协方差的意义和计算公式
- Java研发知识图谱【互联网行业】
- Java类修饰符
- 深入浅出JMS(一)--JMS基本概念
- Android-Tips
- 负载均衡时,在State_Server模式中的Session共享问题(不讨论负载均衡的问题)
- JAVA中数个字符串转换为JSON格式的字符串