I get compilation error when I do this cast:
RandomAccessFile raf = new RandomAccessFile(...)
InputStream is = (InputStream)raf;
Rand
RandomAccessFile is supposed to extends InputStream although not directly.
No it isn't. See the Javadoc.
From docs:
RandomAccessFile
implementsDataInput
which in turnDataInputstream
&InputStream.
That's not 'from the docs' at all. You made it up. What you've written doesn't even make sense. DataInput
is an interface. DataInputStream
and InputStream
are classes. Interfaces don't implement, or extend, classes.
What the Javadoc actuallys says is that RandomAccessFile
extends java.lang.Object
and implements Closeable, DataInput, DataOutput
.