读取HTTP链接文件 到本地文件
来源:互联网 发布:dobbox源码怎么看 编辑:程序博客网 时间:2024/05/17 07:19
package com.test1;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import java.io.UnsupportedEncodingException;import java.net.MalformedURLException;import java.net.URL;import java.net.URLConnection;import java.net.URLEncoder;public class IO2 {public static void main(String[] args) throws IOException {FileOutputStream fo= null;String path = "http://test";String remoteFileName = "http://test";URL url = new URL(path+URLEncoder.encode(remoteFileName,"utf-8")); URLConnection conn = url.openConnection(); try { //FileInputStream in=new FileInputStream(path+URLEncoder.encode(remoteFileName,"utf-8")); InputStream is = conn.getInputStream(); File file=new File("D:/test.pdf"); if(!file.exists()) file.createNewFile(); FileOutputStream out=new FileOutputStream(file); int c; byte buffer[]=new byte[is.available()]; while((c=is.read(buffer))!=-1){ for(int i=0;i<c;i++) out.write(buffer[i]); } is.close(); out.close();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();} }}
0 0
- 读取HTTP链接文件 到本地文件
- 读取本地文件上传到数据库
- 保存页面文本到本地文件&&读取本地文件内容到页面
- 使用Java读取xlxs文件和写入txt文件,并将数据写入到本地文件
- C#各种扩展名文件存入sql server数据库及读取到本地文件
- Java读取本地文件,然后把数据存到mysql.(以csv文件为例)
- OC如何读取本地文件和网络文件
- Spark Streaming 读取本地文件压文件
- .net利用npoi读取本地文件excel文件
- 通过java的io流将本地文件读取到控制台,并将文件内容再次写入另一个文件中
- 【python coding 2:文件读写】读取本地文件里的ip地址,循环写入到新的文件中
- 读取本地文件
- 读取本地文件
- 读取本地文件
- 合并本地文件到HDFS文件中
- 保存文件到本地and加载本地文件
- 文件链接读取程序
- 将页面信息保存到本地文件和读取本地文件信息到页面
- xcode 使用方法初探--第一个objective-c程序
- 黑马程序员 IO笔记
- Android长度单位详解
- android gralloc 流程分析
- 执行堆上的一块代码调用
- 读取HTTP链接文件 到本地文件
- 生成器表达式
- eclipse下的web Project
- layer绘制阴影后造成的滚动卡顿
- memory 子系统
- Android基础概况
- [个性化你的App]iOS:实现类似于google+的tableviewcell卡片式插入效果
- [转]Cocos2d-X 程序是如何开始运行与结束的
- 计算机网络中的小端大端