纯JAVA HTTPURL 访问制定url地址返回页面数据
来源:互联网 发布:海森伯格矩阵是什么 编辑:程序博客网 时间:2024/05/16 15:28
package HttpConn;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Map;
import javax.net.ssl.HttpsURLConnection;
public class ConnUrl {
public static void main(String args[]) throws IOException{
requestData("你的URL地址",null);
URL url=new URL(urlString);
HttpsURLConnection openConnection=(HttpsURLConnection)url.openConnection();
openConnection.setReadTimeout(10000);
openConnection.setConnectTimeout(10000);
BufferedReader br=new BufferedReader(new InputStreamReader(openConnection.getInputStream(),"UTF-8"));
StringBuffer stringBuffer=new StringBuffer();
String s =null;
while((s = br.readLine())!=null){
stringBuffer.append(s+"\n");
}
System.out.println(stringBuffer);
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Map;
import javax.net.ssl.HttpsURLConnection;
public class ConnUrl {
public static void main(String args[]) throws IOException{
requestData("你的URL地址",null);
}
URL url=new URL(urlString);
HttpsURLConnection openConnection=(HttpsURLConnection)url.openConnection();
openConnection.setReadTimeout(10000);
openConnection.setConnectTimeout(10000);
BufferedReader br=new BufferedReader(new InputStreamReader(openConnection.getInputStream(),"UTF-8"));
StringBuffer stringBuffer=new StringBuffer();
String s =null;
while((s = br.readLine())!=null){
stringBuffer.append(s+"\n");
}
System.out.println(stringBuffer);
}
}
以和风天气API为例返回结果
阅读全文
1 0
- 纯JAVA HTTPURL 访问制定url地址返回页面数据
- java httpURL连接远程服务器并返回数据(httpurlconnection)
- java httpURL连接远程服务器并返回数据(httpurlconnection)
- java httpURL连接远程服务器并返回数据(httpurlconnection)
- java httpURL连接远程服务器并返回数据(httpurlconnection)
- java httpURL连接远程服务器并返回数据(httpurlconnection)
- java httpURL连接远程服务器并返回数据(httpurlconnection)
- java httpURL连接远程服务器并返回数据(httpurlconnection)
- java httpURL连接远程服务器并返回数据(httpurlconnection)
- java httpURL连接远程服务器并返回数据(httpurlconnection)
- 纯静态html页面,js 如何拦截请求url的后缀不是.html的访问地址
- 纯静态html页面,js 如何拦截请求url的后缀不是.html的访问地址
- java URL 访问远程地址,得到 xml 数据....
- C#访问URL地址并返回值
- 纯java方式访问远程WebService接口返回的xml格式的数据保存在本地
- HttpURL connection URLconnection URL
- 用java程序直接访问URL地址
- 访问页面返回XML格式的数据
- 知道这20个正则表达式,能让你少写1,000行代码
- Faster RCNN 源码解读(2) -- NMS(非极大抑制)
- 文章标题
- [自制操作系统] BMP格式文件读取&图形界面系统框架-应用接口设计
- leetcode 552. Student Attendance Record II & 600. Non-negative Integers without Consecutive Ones
- 纯JAVA HTTPURL 访问制定url地址返回页面数据
- Contest1255
- 原生链
- (算法分析Week2)3Sum[Medium]
- python类继承需要注意的问题
- PowerDesigner连接MySQL,建立逆向工程图解
- 查看缩略图dome.html
- Faster RCNN 源码解读(3.1) -- RPN源码结构介绍
- python爬取网页并作简单处理(python2.7.1) 一