Java复制二进制文件

2019-10-14| 发布者: admin| 查看: |

 
BufferedInputStream和BufferedOutputStream


 

import java.io.*;
public class BufferCopy {
 public static void main {
 //定义一个高效缓存字节流
 BufferedInputStream in = null;
 BufferedOutputStream out = null;
 try {
 //创建一个高效缓存字节流对象
 in = new BufferedInputStream);
 out = new BufferedOutputStream);
 //定义一个字节数组
 byte[] bs = new byte[1024];
 //定义一个标志
 int len = -1;
 while) != -1){
 out.write;
 } catch  {
 e.printStackTrace;
 } finally {
 try {
 if{
 out.close;
 if{
 in.close;
 } catch  {
 e.printStackTrace;
}