当前位置:网站首页>Realization of file copy
Realization of file copy
2020-11-08 21:03:00 【8Years】
public class TestIO01 {
public static void main(String[] args) {
copy("D:/aaa.txt","D:/B.txt");// Copy the contents of the former file into the latter 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]所创,转载请带上原文链接,感谢
边栏推荐
- iptables从入门到掌握
- abp(net core)+easyui+efcore实现仓储管理系统——出库管理之五(五十四)
- 存储过程动态查询处理方法
- 动态规划之子序列问题解题模板
- Newbe.ObjectVisitor Example 1
- Five phases of API life cycle
- Not a programmer, code can't be too ugly! The official writing standard of Python: pep8 everyone should know
- Array acquaintance
- Iptables from introduction to mastery
- Computer network application layer
猜你喜欢
Constructors and prototypes
Creating a text cloud or label cloud in Python
CMS garbage collector
构造回文的最小插入次数
If the programming language as martial arts unique! C++ is Jiu Yin Jing. What about programmers?
Dynamic planning
Brief introduction of Integrated Architecture
Regular backup of WordPress website program and database to qiniu cloud
采用注解+拦截器的方式进行异步执行的实现方式
Part 1 - Chapter 2 pointer operation
随机推荐
Using GaN based oversampling technique to improve the accuracy of model for mortality prediction of unbalanced covid-19
Iterm2 configuration and beautification
Django之简易用户系统(3)
Mongodb add delete modify query operation
Decorator (1)
用两个栈实现队列
第一部分——第1章概述
Newbe.ObjectVisitor Example 1
使用基于GAN的过采样技术提高非平衡COVID-19死亡率预测的模型准确性
装饰器(二)
npm install 无响应解决方案
文件拷贝的实现
Infix expression to suffix expression
【Elasticsearch 技术分享】—— 十张图带大家看懂 ES 原理 !明白为什么说:ES 是准实时的!
Solve the problem that the value of new date() of JS in IE and Firefox is invalid date and Nan Nan
存储过程动态查询处理方法
The minimum insertion times of palindrome
Looking for better dynamic getter and setter solutions
Not a programmer, code can't be too ugly! The official writing standard of Python: pep8 everyone should know
Dynamic ReLU:微软推出提点神器,可能是最好的ReLU改进 | ECCV 2020