/*
采用字节缓冲流读写字节数组的方式复制文件
*/
public class Demo6 {
public static void main(String[] args) throws IOException {
//1.创建字节缓冲输入流对象
BufferedInputStream bis = new BufferedInputStream(new FileInputStream("Practice\\text.txt"));
//2.创建字节缓冲流输出流对象
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("Practice\\textback.txt"));
//3.进行读写过程
byte[] b = new byte[1024];
int len = 0;
while ((len = bis.read(b)) != -1){
bos.write(b,0,len);
}
bis.close();
bos.close();
}
}
字节缓冲流复制文件常用方法
最新推荐文章于 2024-09-26 16:29:56 发布