Java 文件拷贝
来源:互联网 发布:excel 对数据进行统计 编辑:程序博客网 时间:2024/05/22 03:42
1.使用流
InputStream is = null;
OutputStream os = null;
try {
is = new FileInputStream(source);
os = new FileOutputStream(dest);
byte[] buffer = new byte[1024];
int length;
while ((length = is.read(buffer)) > 0) {
os.write(buffer, 0, length);
}
} finally {
is.close();
os.close();
}
}
2 使用管道
FileChannel sourceChannel = null;
FileChannel destChannel = null;
try {
sourceChannel = new FileInputStream(source).getChannel();
destChannel = new FileOutputStream(dest).getChannel();
destChannel.transferFrom(sourceChannel, 0, sourceChannel.size());
}finally{
sourceChannel.close();
destChannel.close();
}
}
3 commons io
FileUtils.copyFile(source, dest);
}
4 java7 File Class
Files.copy(source.toPath(), dest.toPath());
}
0 0
- java文件拷贝
- Java拷贝文件
- java实现文件拷贝
- java编程文件拷贝
- Java拷贝大文件
- java拷贝文件代码
- java文件拷贝
- Java 文件拷贝
- java 文件拷贝操作
- java拷贝文件
- Java 拷贝文件内容
- java文件拷贝
- java之 ------ 文件拷贝
- Java文件拷贝
- java文件拷贝类
- Java文件拷贝
- java文件的拷贝
- Java---IO文件拷贝
- 标签切换
- 使用VS2005创建COM
- poj 2482 Stars in Your Window(线段树+扫描线)
- mongodb中的group功能
- eclipse配置spket
- Java 文件拷贝
- cocos2dx中的屏幕大小
- 内部类与匿名内部类区别和应用
- hadoop DistributeCatche使用代码片段
- WPF 数据绑定需要注意的地方
- DllMain详解
- 我会陷入到一种迷茫而又不知所终的状态里
- Subversion快速入门教程
- java接口与抽象类区别