使用缓冲流和byte数组,拷贝文件
2024-08-25 23:29:30
package com.itcast.demo05.Buffered;
import java.io.*;
/**
* @author newcityman
* @date 2019/7/28 - 17:05
*/
public class BufferedCopy {
public static void main(String[] args) throws IOException {
long s = System.currentTimeMillis();
BufferedInputStream bis = new BufferedInputStream(new FileInputStream("H:\\IMG_7621.JPG"));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("e:\\IMG_7621.JPG"));
int len=0;
byte[] bytes = new byte[2048];
while((len=bis.read(bytes))!=-1){
bos.write(bytes,0,len);
}
bos.close();
bis.close();
long e = System.currentTimeMillis();
System.out.println("拷贝文件总共耗时:"+(e-s)+"毫秒");
}
}
最新文章
- CentOS 7 Git安装
- zepto区别于jquery获取select表单选中的值
- RedHat/Centos修改root密码
- Bootstrap相关总结
- [转] 主流JS框架中DOMReady事件的实现
- Android项目实战(二十):浅谈ListView悬浮头部展现效果
- Eclipse在线安装ADT插件
- changing a pointer rather than erasing memory cells
- Ruby相关图书推荐
- Read Asia Embedded fell
- MVC5 学习资料
- NGUI字体贴图压缩以及相关Shader解读
- 【屌丝程序的口才逆袭演讲稿50篇】第十篇:程序猿们请看看外面的世界吧【张振华.Jack】
- Caffe学习系列(一)Ubuntu16.04下搭建编译Caffe环境,并运行MNIST示例(仅CPU)
- 20170713_js闭包/匿名函数/作用域
- Spring JDBC(二)SimpleJdbcInsert
- 制作windows系统合盘:把win7和win8/8.1打包在一起
- SpringBoot文件上传(MVC情况和webFlux情况)
- Perl构建和打包自己的模块
- Nginx IP地址透传