get请求
来源:互联网 发布:智能电视专用软件 编辑:程序博客网 时间:2024/06/06 11:20
public static String downloadUrl(String url){String strRet="";if(url!=null){BufferedReader reader=null;HttpURLConnection httpTarget=null;InputStream input = null;try{URL target=new URL(url);httpTarget=(HttpURLConnection)target.openConnection();httpTarget.setConnectTimeout(5000);//设置连接主机超时(单位:毫秒)httpTarget.setReadTimeout(5000);//设置从主机读取数据超时(单位:毫秒)httpTarget.setRequestMethod("GET");httpTarget.setDoInput(true);input = httpTarget.getInputStream();reader=new BufferedReader(new UnicodeReader(input,"UTF-8"));StringBuffer strBuffer=new StringBuffer(1024);String line=reader.readLine();while(line!=null){strBuffer.append(line);line=reader.readLine();}strRet=strBuffer.toString();}catch(Exception ex){System.out.println("连接到"+url+"出错!"+ex);strRet="";}finally{if(reader != null){try {reader.close();} catch (IOException e) {e.printStackTrace();}}if(input != null){try {input.close();} catch (IOException e) {e.printStackTrace();}}httpTarget.disconnect();}}return strRet;}
0 0
- get请求
- Get请求
- get请求
- GET请求
- get请求
- GET请求
- get请求
- get请求
- GET请求 Post请求
- get请求 post请求
- Get请求 Post请求
- get请求和post请求
- get请求和post请求
- GET请求和POST请求
- IOS-post请求、get请求
- GET请求和POST请求
- GET请求和POST请求
- GET请求和POST请求
- WmiPrvSE.exe内存占用异常
- highcharts各个元素功能
- 查询oracle表的信息(表,字段,约束,索引)
- Tenth Line
- 利用Hog特征和SVM分类器进行行人检测
- get请求
- Sublime Text 2下安装SFTP插件
- 第三周顺序表的应用(1)
- iOS学习笔记29-__block 与 __weak的区别理解
- Linux高可用性方案之Heartbeat安装
- nyoj 68 三点顺序
- VS2015中配置Pthread
- SRM 668 DIV 2 IsItASquare 600-point
- Qt 与 xcode 7版本的问题