发送HTTP数据流以及HTTPS数据流
来源:互联网 发布:推荐钢琴弹奏软件 编辑:程序博客网 时间:2024/05/21 17:20
HTTP数据流:
public String getRequest(String surl, String encoding) throws IOException {
String sresult = "";
HttpURLConnection conn = null;
try {
URL url = new URL(surl);
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setDoOutput(false);
System.setProperty("sun.net.client.defaultConnectTimeout",
"1500");
System.setProperty("sun.net.client.defaultReadTimeout", "1500");
InputStream in = conn.getInputStream();
InputStreamReader isr = new InputStreamReader(in, encoding);
char[] b = new char[255];
StringBuffer sb = new StringBuffer();
int len = 0;
while ((len = isr.read(b)) > 0) {
sb.append(b, 0, len);
}
sresult = sb.toString();
isr.close();
in.close();
conn.disconnect();
} catch (IOException e) {
throw e;
} finally {
if (conn != null) {
conn.disconnect();
}
}
return sresult;
}
HTTPS数据流
public void content(String url){
try{
URL reqURL = new URL(url);
HttpsURLConnection httpsConn = (HttpsURLConnection)reqURL.openConnection();
// HttpURLConnection urlCon = (HttpURLConnection)reqURL.openConnection();
// urlCon.setConnectTimeout(3000);//设置连接超时时间
// urlCon.setReadTimeout(3000);//设置响应超时时间
//取得该连接的输入流,以读取响应内容
InputStreamReader insr = new InputStreamReader(httpsConn.getInputStream());
//读取服务器的响应内容并显示
int respInt = insr.read();
while( respInt != -1){
System.out.print((char)respInt);
respInt = insr.read();
}
}catch(Exception e){
e.printStackTrace();
}
}
- 发送HTTP数据流以及HTTPS数据流
- 实时分析HTTP/HTTPS数据流(HTTP Analyzer)
- 数据流
- 数据流
- 数据流
- 数据流
- 数据流
- 数据流
- php 图片转成数据流发送
- VPOS MAS-CNP接口——接收通过https发送来的XML数据流
- .net http接收数据流一样
- HTTP Referer 以及 跳转 以及 https不能发送HTTP Referer
- 获取http传输过来的http数据流
- linux网卡数据流 发送与接收
- darwin之发送数据流(ReflectorSession)
- Soot数据流 -- 数据流框架
- VPOS MAS-CNP接口——建立https连接发送请求并接收返回的XML数据流
- C# Post数据流到HTTP地址
- 傻瓜教程:笔记本XP+ubuntu9.10+保留一键恢复 理想达成!
- Android/Ophone中的悬浮对话框和即点即关对话框
- 又一片天地
- 获取服务器MAC地址以及相关网络信息
- 迭代网络数据头信息 以及获取客户端真实IP
- 发送HTTP数据流以及HTTPS数据流
- [原创]java applet Calculator 计算器,仿照Windows计算器
- 【原创】java applet Clock + Timer时钟或者电子钟也行,计时功能
- 记住,倍增你的学习力
- (转)散分+一些跳槽经验分享
- 免费讲座:BootLoader应用与移植!明晚开讲敬请期待...
- Windows 2003 IIS 不支持ASP的问题
- 分析与设计数据库模型的简单过程
- 希望有一天我会变成变成编程大王~