【Java】字节流复制文本文件
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class CopyTxtDemo {
public static void main(String[] args) throws IOException {
FileInputStream fis=new FileInputStream("D:\\MyProject\\Java\\LearnJava1\\src\\Demo4\\fos.txt");
FileOutputStream fos=new FileOutputStream("D:\\MyProject\\Java\\LearnJava1\\src\\Demo4\\fos2.txt");
// 读写数据
int by;
while ((by=fis.read())!=-1){
fos.write(by);
}
// 释放资源
fis.close();
fos.close();
}
}
本文来自博客园,作者:木子欢儿,转载请注明原文链接:https://www.cnblogs.com/HGNET/p/16167081.html