Вы можете проверить размер файла на диске, создать соответствующий буфер и использовать этот метод для чтения, чтобы сделать объемную нагрузку (как вы можете видеть, что это вызывает родные readBytes). Конечно, я понятия не имею, если нет петли внутри readBytes (скорее всего, есть, но это может зависеть от реализации JVM) ... :)
В FileInputStream
/**
* Reads up to <code>b.length</code> bytes of data from this input
* stream into an array of bytes. This method blocks until some input
* is available.
*
* @param b the buffer into which the data is read.
* @return the total number of bytes read into the buffer, or
* <code>-1</code> if there is no more data because the end of
* the file has been reached.
* @exception IOException if an I/O error occurs.
*/
public int read(byte b[]) throws IOException {
возврата readBytes (b, 0, b.length); }
/**
* Reads up to <code>len</code> bytes of data from this input stream
* into an array of bytes. If <code>len</code> is not zero, the method
* blocks until some input is available; otherwise, no
* bytes are read and <code>0</code> is returned.
*
* @param b the buffer into which the data is read.
* @param off the start offset in the destination array <code>b</code>
* @param len the maximum number of bytes read.
* @return the total number of bytes read into the buffer, or
* <code>-1</code> if there is no more data because the end of
* the file has been reached.
* @exception NullPointerException If <code>b</code> is <code>null</code>.
* @exception IndexOutOfBoundsException If <code>off</code> is negative,
* <code>len</code> is negative, or <code>len</code> is greater than
* <code>b.length - off</code>
* @exception IOException if an I/O error occurs.
*/
public int read(byte b[], int off, int len) throws IOException {
возврата readBytes (б, выключена, LEN); }
Как вы думаете, что происходит в магическом методе, в котором вы проходите число? –
hahahaha, очевидно, цикл: d – sajjoo
, но мой руководитель команды заставлял меня искать какую-то вещь, которую я спросил у него в методе, там должен быть цикл, но он сказал нет, это может быть иначе. – sajjoo