Java: 使用长偏移量和长度参数调用 InputStream.read

Java: Calling InputStream.read with long offset and length parameters

在 InputStream 对象上调用 read 方法时,offlen 参数为 longs,显然不能这样做:

The method read(byte[], int, int) in the type InputStream is not applicable for the arguments (byte[], long, long)

真的必须分块阅读吗?有一些简单的解决方法吗?为什么他们不能超载?

Java Language Specification

中所述

Arrays must be indexed by int values; short, byte, or char values may also be used as index values because they are subjected to unary numeric promotion (§5.6.1) and become int values.

提供 byte[]long len 根本没有意义。不存在这样的API。