read(byte[] b) 和read(byte[] b, int off, int len) 有什么区别?

为什么read(byte[] b)进行文本读写会丢失内容?
而read(byte[] b, int off, int len) 不会。

因为第一个受限于数组 b 的长度,如果内容过多,而缓冲区只有固定这么多,就只能读取 b.length 的数据。
第二个,固定读取指定 length 的长度,也可能存在读取不完整的情况。
两种方式都需要循环输入流,直到没有数据为止。