java 访问http
2016-06-03 14:48
369 查看
public static String getURLContent(String urlStr) { /** 网络的url地址 */ URL url = null; /** http连接 */ HttpURLConnection httpConn = null; /**//** 输入流 */ BufferedReader in = null; StringBuffer sb = new StringBuffer(); try{ url = new URL(urlStr); in = new BufferedReader( new InputStreamReader(url.openStream(),"UTF-8") ); String str = null; while((str = in.readLine()) != null) { sb.append( str ); } } catch (Exception ex) { } finally{ try{ if(in!=null) { in.close(); } }catch(IOException ex) { } } String result =sb.toString(); return result; }
相关文章推荐
- Python socket编程,tcp和udp
- 数字僵尸之战:《行尸走肉》S6启示
- 大规模DDoS攻击来了宝宝一开始也慌了
- 【iOS开发】HTTP请求错误码 ? CodeType
- 创建容器Error response from daemon: dial tcp 72.52.4.91:8080: connection refused
- http请求的get和post
- 14、python网络编程(二)
- 20150603开发板网络配置
- iOS http协议的解决
- TCP与UDP的区别
- iOS 网络加载转码
- Linux_常用网络配置文件介绍
- HTTP 传输类型&MIME类型 整理
- 逆向工程 - Reveal、IDA、Hopper、https抓包 等
- tcp标志push与发送窗口的关系
- 配置KVM虚拟机的网络 Bridge和Nat方式
- java Tcp/ip网络编程
- 关于启用 HTTPS 的一些经验分享
- 13、python网络编程练习(一)
- TCP的几个状态 (SYN, FIN, ACK, PSH, RST, URG)