For the best Java read performance, there are four things to remember:
- Minimize I/O operations by reading an array at a time, not a byte at a time. An 8Kbyte array is a good size.
- Minimize method calls by getting data an array at a time, not a byte at a time. Use array indexing to get at bytes in the array.
- Minimize thread synchronization locks if you don't need thread safety. Either make fewer method calls to a thread-safe class, or use a non-thread-safe class like
- Minimize data copying between the JVM/OS, internal buffers, and application arrays. Use
FileChannelwith memory mapping, or a direct or wrapped array