public int read (byte[] b, int off, int len) throws IOException

Reads up to len bytes of data from this file into an array of bytes. This method blocks until at least one byte of input is available.

Although RandomAccessFile is not a subclass of InputStream, this method behaves in exactly the same way as the InputStream.read(byte[], int, int) method of InputStream.

Parameters:
b    the buffer into which the data is read.
off    the start offset in array b at which the data is written.
len    the maximum number of bytes read.

Returns:  the total number of bytes read into the buffer, or -1 if there is no more data because the end of the file has been reached.

Exceptions:
IOException    If the first byte cannot be read for any reason other than end of file, or if the random access file has been closed, or if some other I/O error occurs.
NullPointerException    If b is null.
IndexOutOfBoundsException    If off is negative, len is negative, or len is greater than b.length - off