package com.test.abc;
import java.io.*;
public class Demo1 {
public static void main(String[] args) throws IOException {
// 创建缓冲字节输入流
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File("d:/java/a.txt")));
// 创建缓冲字节输出流
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File("d:/jad/a.txt")));
// 创建缓冲数组
byte[] a = new byte[10240];
// for循环遍历数组
int length;
// 把数据从磁盘写入内存
while ((length = bis.read(a)) != -1) {
// 把数据从内存写入新地址
bos.write(a, 0, length);
}
// 关闭字节输出流
bos.close();
// 关闭字节输入流
bis.close();
}
}
JAVA IO流案例 复制一个文本文档到另外一个目录下
最新推荐文章于 2023-09-22 16:10:36 发布