http的post方法
来源:互联网 发布:数据分析报告范例 编辑:程序博客网 时间:2024/05/22 02:24
http的post方法
class ReadByPost extends Thread { @Override public void run() { super.run(); String targetUrl = "https://api.douban.com/v2/book/search"; try { URL url = new URL(targetUrl); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.addRequestProperty("encoding", "UTF-8"); con.setDoInput(true); con.setDoOutput(true); con.setRequestMethod("POST"); OutputStream os = con.getOutputStream(); OutputStreamWriter osw = new OutputStreamWriter(os); BufferedWriter bw = new BufferedWriter(osw); bw.write("q=软件工程"); bw.flush(); InputStream is = con.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line; StringBuilder sb = new StringBuilder(); while ((line = br.readLine()) != null) { sb.append(line); } bw.close(); osw.close(); os.close(); br.close(); isr.close(); is.close(); System.out.println(sb.toString()); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }}
0 0
- http的post方法
- HTTP POST方法的学习
- HTTP Post方法应用的例子
- HTTP Post方法应用的例子
- HTTP GET与POST方法的区别
- 发送Http请求(POST GET)的方法
- 实现HTTP-POST的Edit Action方法
- 发送Http请求(POST GET)的方法
- Http的get和post方法比较
- HTTP中POST方法的实现
- 发送Http请求(POST GET)的方法
- 发送Http请求(POST GET)的方法
- 发送Http请求(POST GET)的方法
- 发送Http请求(POST GET)的方法
- CURL实现HTTP的GET POST方法
- iOS HTTP协议的get,post方法
- 发送HTTP请求的方法:GET & POST
- http中get和post的方法
- python离线环境
- 拖拽、移动元素的JS原生函数
- static 关键字
- spring整合hibernate时报的错
- 《APUE》读书笔记—第九章进程关系
- http的post方法
- css background详解
- tippecanoe
- ES修改默认的密码信息
- Linux execl()函数练习
- GDOI第二轮模拟总结
- @SerializedName注解
- POJ 1797 (最短路变形)
- 软件测试基础-应急必备大全