java复制文件
2024-08-19 18:26:25
package com.test.tes; import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Date; /**
* 复制文件到指定目录下
* @author Wdnncey
*
*/ public class Copy { public static long forJava(File f1,File f2) throws Exception{
long time=new Date().getTime();
int length=2097152;
FileInputStream in=new FileInputStream(f1);
FileOutputStream out=new FileOutputStream(f2);
byte[] buffer=new byte[length];
while(true){
int ins=in.read(buffer);
if(ins==-1){
in.close();
out.flush();
out.close();
return new Date().getTime()-time;
}else
out.write(buffer,0,ins);
}
} public static void main(String[] args) {
try {
forJava(new File("1.zip"), new File("e:\\a\\b\\2.zip"));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }
最新文章
- 让div固定在顶部不随滚动条滚动
- delphi 10 seattle 安卓服务开发(三)
- iOS:iOS开发非常全的三方库、插件等等
- Android——ScrollView
- POJ1948Triangular Pastures(DP)
- IOS UITableView Group&;Section
- XML操作:2.LINQ TO XML(http://www.cnblogs.com/AlexLiu/archive/2008/10/27/linq.html)
- 【转】移动互联网应用测试成长技能树V1.0
- iOS 9 适配需要注意的问题
- mysql 基础技术
- [黑马程序员] 集合框架2——Map系 &; 集合工具类(Collections、Arrays)
- asp.net 输出Excel
- JavaScript小括号、中括号、大括号的多义性
- kaldi chain模型的序列鉴别性训练代码分析
- SharePoint Framework 基于团队的开发(二)
- Linux企业运维人员最常用150个命令汇总 [转]
- Linux - iptable 限制 IP 访问端口
- chromium ⑤
- es6学习笔记8--Map数据结构
- qualcomm permission denied for tty device