当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- Part 1 - Chapter 2 pointer operation
- Mongodb add delete modify query operation
- 程序员都应该知道的URI,一文帮你全面了解
- Five factors to consider before choosing API management platform
- Mongodb database
- JVM真香系列:轻松理解class文件到虚拟机(下)
- Octave basic syntax
- getBytes之 LengthFieldBasedFrameDecoder服务端解析
- 线程池运用不当的一次线上事故
- 接口测试工具Eolinker进行post请求
猜你喜欢
Django之简易用户系统(3)
Solve the problem that the value of new date() of JS in IE and Firefox is invalid date and Nan Nan
使用Fastai开发和部署图像分类器应用
Process thread coroutine
【Elasticsearch 技术分享】—— 十张图带大家看懂 ES 原理 !明白为什么说:ES 是准实时的!
Implementation of warehouse management system with ABP (net core) + easyUI + efcore
第一部分——第1章概述
Learn volatile, you change your mind, I see
使用基于GAN的过采样技术提高非平衡COVID-19死亡率预测的模型准确性
在Python中创建文字云或标签云
随机推荐
装饰器(二)
Using GaN based oversampling technique to improve the accuracy of model for mortality prediction of unbalanced covid-19
Introduction and application of swagger
LeetCode 45 跳跃游戏II
CountDownLatch 瞬间炸裂!同基于 AQS,凭什么 CyclicBarrier 可以这么秀?
Dynamic planning
Dynamic query processing method of stored procedure
在Python中创建文字云或标签云
使用Fastai开发和部署图像分类器应用
Constructors and prototypes
Swagger介绍和应用
Case analysis of entitycore framework
[cloud service] there are so many ECS instances on alicloud server, how to select the type? Best practice note
Tasks of the first week of information security curriculum design (analysis of 7 instructions)
都说程序员钱多空少,程序员真的忙到没时间回信息了吗?
存储过程动态查询处理方法
PAT_ Grade A_ 1056 Mice and Rice
Copy the picture
在Python中创建文字云或标签云
AI人工智能编程培训学什么课程?