当前位置:网站首页>文件拷贝的实现
文件拷贝的实现
2020-11-08 21:03:00 【8Years】
public class TestIO01 {
public static void main(String[] args) {
copy("D:/aaa.txt","D:/B.txt");//把前者文件的内容拷贝到后者文件中qu
}
public static void copy(String srcfile,String destpath) {
File file=new File(srcfile);
File file1=new File(destpath);
InputStream is=null;
OutputStream os=null;
try {
is=new FileInputStream(file);
os=new FileOutputStream(file1);
byte[] car=new byte[3];
int temp;
int len;
while((len=is.read(car))!=-1){
os.write(car,0, len);
String str=new String(car,0,len);
}
os.flush();
} catch (FileNotFoundException fileNotFoundException) {
fileNotFoundException.printStackTrace();
} catch (IOException ioException) {
ioException.printStackTrace();
}finally{
try{
if(is!=null){
is.close();
}
}catch (IOException ioException){
ioException.printStackTrace();
}
try{
if(is!=null){
is.close();
}
}catch (IOException ioException){
ioException.printStackTrace();
}
}
}
}
版权声明
本文为[8Years]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4583813/blog/4707700
边栏推荐
猜你喜欢

To introduce to you, this is my flow chart software—— draw.io

Dynamic ReLU:微软推出提点神器,可能是最好的ReLU改进 | ECCV 2020

经典动态规划:最长公共子序列

Constructors and prototypes

Django之简易用户系统(3)

信息安全课程设计第一周任务(7条指令的分析)

程序员都应该知道的URI,一文帮你全面了解

Is parameter passing in go language transfer value or reference?

Wechat applet related

Flink系列(0)——准备篇(流处理基础)
随机推荐
Leetcode 45 jumping game II
【杂谈】JS相关的线程模型整理
为什么需要使用API管理平台
RSA非对称加密算法
Five factors to consider before choosing API management platform
第一部分——第2章指针操作
动态规划答疑篇
How to deploy pytorch lightning model to production
寻找性能更优秀的不可变小字典
C/C++学习日记:原码、反码和补码
RSA asymmetric encryption algorithm
Summary of interface test case ideas
PAT_ Grade A_ 1056 Mice and Rice
C/C++知识分享: 函数指针与指针函数,看完这篇你还能不懂?
WordPress网站程序和数据库定时备份到七牛云图文教程
寻找性能更优秀的动态 Getter 和 Setter 方案
The interface testing tool eolinker makes post request
IT行业薪资一直遥遥领先!十年后的程序员,是否还是一个高薪职业?
Looking for a small immutable dictionary with better performance
Simulink中封装子系统