当前位置:网站首页>文件拷贝的实现
文件拷贝的实现
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
边栏推荐
- Implementation of warehouse management system with ABP (net core) + easyUI + efcore
- Suffix expression to infix expression
- 采用注解+拦截器的方式进行异步执行的实现方式
- 给大家介绍下,这是我的流程图软件 —— draw.io
- 存储过程动态查询处理方法
- net.sf.json . jsonobject's format processing of time stamp
- 实验一作业
- getBytes之 LengthFieldBasedFrameDecoder服务端解析
- Tasks of the first week of information security curriculum design (analysis of 7 instructions)
- 【云服务】阿里云服务器ECS实例规格那么多,如何选型?最佳实践说明
猜你喜欢
Mongodb database
新手入坑指南:工作原因“重启”Deepin系统,发现真的香啊
Using annotation + interceptor to implement asynchronous execution
iptables从入门到掌握
IT industry salary has been far ahead! Ten years later, is the programmer still a high paying profession?
Constructors and prototypes
experiment
To introduce to you, this is my flow chart software—— draw.io
给大家介绍下,这是我的流程图软件 —— draw.io
200 programmers interview experience, all here
随机推荐
net.sf.json.JSONObject对时间戳的格式化处理
11 important operations of Python list
PAT_甲级_1056 Mice and Rice
JVM真香系列:轻松理解class文件到虚拟机(下)
使用基于GAN的过采样技术提高非平衡COVID-19死亡率预测的模型准确性
200 programmers interview experience, all here
EntityFramework Core上下文实例池原理分析
【Elasticsearch 技术分享】—— 十张图带大家看懂 ES 原理 !明白为什么说:ES 是准实时的!
RSA asymmetric encryption algorithm
中缀表达式转后缀表达式
getBytes之 LengthFieldBasedFrameDecoder服务端解析
存储过程动态查询处理方法
【云服务】阿里云服务器ECS实例规格那么多,如何选型?最佳实践说明
[200 interview experience], programmer interview, common interview questions analysis
寻找性能更优秀的动态 Getter 和 Setter 方案
Solve the problem that the value of new date() of JS in IE and Firefox is invalid date and Nan Nan
.NET Core 跨平台资源监控库及 dotnet tool 小工具
VirtualBox安装centos7
JVM真香系列:轻松理解class文件到虚拟机(上)
Constructors and prototypes