৫(”ړ৫)bz 2022-06-15 22:33 采纳率: 88.6%
浏览 13
已结题

java关于输入输出流的习题

没有看懂这一段代码,请问一下为什么运行出来的是4:abcd。是怎么看出来的呀

img

  • 写回答

1条回答 默认 最新

  • 灯塔@kuaidao 2022-06-16 10:01
    关注

    int m=fileInputStream.read(tom);

    这里的read返回值 Int 是读入缓冲区的总字节数,并不是byte tom 缓冲区的大小 100.

     /**
         * Reads up to <code>b.length</code> bytes of data from this input
         * stream into an array of bytes. This method blocks until some input
         * is available.
         *
         * @param      b   the buffer into which the data is read.
         * @return     the total number of bytes read into the buffer, or
         *             <code>-1</code> if there is no more data because the end of
         *             the file has been reached.
         * @exception  IOException  if an I/O error occurs.
         */
        public int read(byte b[]) throws IOException {
            return readBytes(b, 0, b.length);
        }
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 6月24日
  • 已采纳回答 6月16日
  • 创建了问题 6月15日