JAVA通过 URLConnection 获取HTTP接口
来源:互联网 发布:淘宝上买尼康d750港货 编辑:程序博客网 时间:2024/05/29 09:22
工作中遇到的,需要调试接口的时候要调用的,
有需要类似用处的朋友可以借鉴一下.
- public String getResult(String sName)
- {
- String result = "";
- try
- {
- URL uAddr = new URL("http://xxx.xxx.com/xxx/xxx.jsp?xxx="+java.net.URLEncoder.encode(sName,"UTF-8"));
- URLConnection conn = uAddr.openConnection();
- conn.setDoInput(true);
- conn.setDoOutput(false);
- conn.setConnectTimeout(2000);
- BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
- String inputLine;
- while ((inputLine = in.readLine()) != null) result = inputLine;
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- return result;
- }
0 0
- JAVA通过 URLConnection 获取HTTP接口
- JAVA通过 URLConnection 获取HTTP接口
- java 使用URLConnection 进行HTTP接口调用
- Http URLConnection 接口
- 通过java.net.URLConnection发送HTTP请求的方法
- 通过java.net.URLConnection发送HTTP请求的方法
- 通过java.net.URLConnection发送HTTP请求的方法
- 通过java.net.URLConnection发送HTTP请求的方法
- 通过java.net.URLConnection发送HTTP请求的方法
- 通过java.net.URLConnection发送HTTP请求的方法
- 通过java.net.URLConnection发送HTTP请求的方法
- 通过java.net.URLConnection发送HTTP请求的方法
- 通过java.net.URLConnection发送HTTP请求的方法
- 通过java.net.URLConnection发送HTTP请求的方法
- 通过java.net.URLConnection发送HTTP请求的方法
- 通过java.net.URLConnection发送HTTP请求的方法
- 通过java.net.URLConnection发送HTTP请求的方法
- 通过java.net.URLConnection发送HTTP请求的方法
- 效率最高的Excel数据导入
- restful Web 服务编程,REST 与 SOAP
- Longest Consecutive Sequence 【LeetCode】
- C/C++的类型安全
- 森纵怎么走
- JAVA通过 URLConnection 获取HTTP接口
- iOS系统的Javascript与Objective-C互操作指南
- User breakpoint called from code at 0x7c92120e
- GridLayout—网格布局
- bootstreap2中标签页(tab)无法响应的问题
- ANdroid如何实现网络重定向以及使用DownLoadManager类下载
- 安卓getevent和sendevent的使用
- 为什么走线选择50欧姆阻抗
- 百度推广教程