java 出错的地方 while((readCount = bi.read(bytes))!= -1) bo.write(bytes, 0, readCount); 爆红了

java: 找不到符号
符号: 方法 read(byte[])
位置: 类型为java.io.BufferedOutputStream的变量 bi

 public static void main(String[] args) {
        //创建缓冲输出流对象
        BufferedOutputStream bi =new BufferedOutputStream(new FileOutputStream("D:\\"));
        //创建缓冲输入流对象
        BufferedInputStream bo =new BufferedInputStream(new FileInputStream(""));
        long start = System.currentTimeMillis();
        //边读边写
        //单字节
        //copy1(bi,bo);
        //多字节的方式
        int readCount;
        byte[] bytes = new byte[1024];
        while((readCount = bi.read(bytes))!= -1) bo.write(bytes, 0, readCount);
        long end = System.currentTimeMillis();
        System.out.println("耗时:"+(end - start)+ "ms");
        // close
        bi.close();
        bo.close();
    }

    private static void copy1(BufferedInputStream bi, BufferedOutputStream bo) throws IOException{
        int readData;
        while ((readData =bi.read()) != -1){
            bo.write(readData);
        }
    }
}

img

BufferedOutputStream 只有write方法

img


你自己命名时搞混了

img