唐祖庭 2021-10-23 15:57 采纳率: 95.9%
浏览 29
已结题

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

  • 写回答

1条回答 默认 最新

  • huang_ftpjh 2021-10-23 16:46
    关注

    BufferedOutputStream 只有write方法

    img


    你自己命名时搞混了

    img

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 10月31日
  • 已采纳回答 10月23日
  • 创建了问题 10月23日

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作