In Java: is where a way to create a subarray that will point to a portion of a bigger array?

Creating an array as a "view" of an other array is not possible in Java. But you could use java.nio.ByteBuffer, which is basically the class you suggest in work-around #2. For instance:

ByteBuffer subBuf = ByteBuffer.wrap(big, 200, 100).slice().asReadOnlyBuffer();

No copying involved (some object creation, though). As a standard library class, I'd also assume that ByteBuffer is more likely to receive special treatment wrt. "JIT" optimizations by the JVM than a custom one.


If you want to read a file fast and with low-level access, check the java nio stuff. Here's an example from java almanac.

You can use a mapped byte buffer to navigate within the file content.