资源简介
java访问https网址下载文件,当网页需要下载证书的时候,代码和操作步骤齐全。

代码片段和文件信息
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.HttpClient.*;
import org.apache.commons.httpclient.methods.GetMethod;
public class BasicAuthenticationExample {
public BasicAuthenticationExample() {
}
public static void main(String[] args) throws Exception {
HttpClient client = new HttpClient();
client.getState().setCredentials(AuthScope.ANY_HOST “132.35.87.240“
new UsernamePasswordCredentials(“essmon“ “oracle.123“));
GetMethod get = new GetMethod(“https://132.35.87.240/ruei/export.php?id=10048&date=20121112&date-to=20121113&output=csv“);
get.setDoAuthentication( true );
int status = client.executeMethod( get );
InputStream ins = get.getResponseBodyAsStream();
//按指定的字符集构建文件流
BufferedReader br = new BufferedReader(new InputStreamReader(ins“UTF-8“));
StringBuffer sbf = new StringBuffer();
String line = null;
while ((line = br.readLine()) != null)
{
sbf.append(line);
sbf.append(“\n“);
}
br.close();
System.out.println( sbf.toString());
get.releaseConnection();
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-12-07 11:31 java访问https网址下载文件\
目录 0 2012-12-07 11:26 java访问https网址下载文件\Downloadfile\
文件 530 2012-12-07 11:17 java访问https网址下载文件\Downloadfile\.classpath
文件 388 2012-12-06 16:15 java访问https网址下载文件\Downloadfile\.project
目录 0 2012-12-07 11:26 java访问https网址下载文件\Downloadfile\bin\
文件 2350 2012-12-07 11:25 java访问https网址下载文件\Downloadfile\bin\BasicAuthenticationExample.class
文件 46725 2011-06-24 21:25 java访问https网址下载文件\Downloadfile\commons-codec-1.3.jar
文件 279781 2008-06-25 20:29 java访问https网址下载文件\Downloadfile\commons-httpclient-3.0.1.jar
文件 60686 2012-06-22 11:08 java访问https网址下载文件\Downloadfile\commons-logging-1.1.1.jar
文件 424648 2012-06-22 11:08 java访问https网址下载文件\Downloadfile\httpclient-4.2.jar
文件 223282 2012-06-22 11:08 java访问https网址下载文件\Downloadfile\httpcore-4.2.jar
目录 0 2012-12-07 11:26 java访问https网址下载文件\Downloadfile\src\
文件 1530 2012-12-07 11:25 java访问https网址下载文件\Downloadfile\src\BasicAuthenticationExample.java
文件 274 2012-12-07 11:32 java访问https网址下载文件\使用说明.txt
文件 162 2012-12-07 11:31 java访问https网址下载文件\导入证书脚本.txt
- 上一篇:j2EE编码规范----D:\\文件项目
- 下一篇:java自动组卷系统
相关资源
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- 推荐算法的JAVA实现
- 基于Java的酒店管理系统源码(毕业设
- java-图片识别 图片比较
- android毕业设计
- java23种设计模式+23个实例demo
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- mysql jsp网站源码下载
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
- java期末考试试题两套(答案) 选择(
- JAVA3D编程示例(建模、交互)
- Java 文件加密传输
- java做的房产管理系统
- 基于jsp的bbs论坛 非常详细
- [免费]java实现有障碍物的贪吃蛇游戏
- java Servlet投票实例
- 操作系统作业 (pv,作业管理,等5个
- 基于C/S架构考试系统(Java)
- java access 仓库管理系统 源码
评论
共有 条评论