使用java将a.txt和b.txt中的内容进行替换
发布时间:2023年12月22日
package com.haimeng.test;
import java.io.*;
public class demo_io2 {
public static void main(String[] args) throws IOException {
byte[] buffer = new byte[1024];
int len;
InputStream isa = new FileInputStream("src/com/haimeng/upload/a.txt");
OutputStream osc = new FileOutputStream("src/com/haimeng/upload/c.txt");
while ((len = isa.read(buffer)) != -1){
osc.write(buffer,0,len);
}
osc.close();
isa.close();
InputStream isb = new FileInputStream("src/com/haimeng/upload/b.txt");
OutputStream osa = new FileOutputStream("src/com/haimeng/upload/a.txt");
while ((len = isb.read(buffer)) != -1){
osa.write(buffer,0,len);
}
osa.close();
isb.close();
InputStream isc = new FileInputStream("src/com/haimeng/upload/c.txt");
OutputStream osb = new FileOutputStream("src/com/haimeng/upload/b.txt");
while ((len = isc.read(buffer)) != -1){
osb.write(buffer,0,len);
}
isc.close();
osb.close();
System.out.println("替换成功");
}
}
文章来源:https://blog.csdn.net/N16696796429/article/details/135148196
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:chenni525@qq.com进行投诉反馈,一经查实,立即删除!