I get compilation error when I do this cast:
RandomAccessFile raf = new RandomAccessFile(...)
InputStream is = (InputStream)raf;
Rand
To build on @robert-christian’s answer, the main reason to use RandomAccessFile to begin with is to seek to some position, rather than skipping bytes from a FileInputStream. But then why bother with pre-NIO APIs at all?
try (FileChannel ch = FileChannel.open(Paths.get(…), StandardOpenOption.READ)) {
InputStream is = Channels.newInputStream(ch.position(…));
// …
}