当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- 国内三大云数据库测试对比
- PAT_ Grade A_ 1056 Mice and Rice
- 程序员都应该知道的URI,一文帮你全面了解
- [elastic search technology sharing] - ten pictures to show you the principle of ES! Understand why to say: ES is quasi real time!
- To introduce to you, this is my flow chart software—— draw.io
- 微信小程序相关
- Programmers should know the URI, a comprehensive understanding of the article
- 新手入坑指南:工作原因“重启”Deepin系统,发现真的香啊
- JVM真香系列:轻松理解class文件到虚拟机(上)
- The interface testing tool eolinker makes post request
猜你喜欢
Process thread coroutine
Dynamic relu: Microsoft's refreshing device may be the best relu improvement | ECCV 2020
后缀表达式转中缀表达式
Programmers should know the URI, a comprehensive understanding of the article
CountDownLatch 瞬间炸裂!同基于 AQS,凭什么 CyclicBarrier 可以这么秀?
第一部分——第1章概述
C/C++学习日记:原码、反码和补码
[cloud service] there are so many ECS instances on alicloud server, how to select the type? Best practice note
JVM真香系列:轻松理解class文件到虚拟机(下)
JVM Zhenxiang series: easy understanding of class files to virtual machines (Part 2)
随机推荐
JVM真香系列:轻松理解class文件到虚拟机(上)
都说程序员钱多空少,程序员真的忙到没时间回信息了吗?
Flink series (0) -- Preparation (basic stream processing)
深拷贝
中缀表达式转后缀表达式
Experiment 1 assignment
Decorator (2)
Select sort
简明 VIM 练级攻略
AI人工智能编程培训学什么课程?
Constructors and prototypes
接口测试工具Eolinker进行post请求
Countdownlatch explodes instantly! Based on AQS, why can cyclicbarrier be so popular?
MongoDB数据库
线程池运用不当的一次线上事故
程序员都应该知道的URI,一文帮你全面了解
Not a programmer, code can't be too ugly! The official writing standard of Python: pep8 everyone should know
PAT_ Grade A_ 1056 Mice and Rice
解决go get下载包失败问题
Five phases of API life cycle