Here you can find the source of readBytes(InputStream inputStream, byte[] buffer, int offset, int length)
Parameter | Description |
---|---|
inputStream | source input stream |
buffer | destination buffer |
offset | offset in the buffer |
length | number of bytes to read |
Parameter | Description |
---|---|
EOFException | if end of stream reached |
IOException | if other I/O error occurred |
static void readBytes(InputStream inputStream, byte[] buffer, int offset, int length) throws IOException
//package com.java2s; // Licensed under the MIT license. See LICENSE file in the project root for full license information. import java.io.EOFException; import java.io.IOException; import java.io.InputStream; public class Main { /**// w ww .ja v a 2s . co m * Reads a sequence of bytes from the input, raising an EOFException if end of stream is reached. * * @param inputStream source input stream * @param buffer destination buffer * @param offset offset in the buffer * @param length number of bytes to read * @throws EOFException if end of stream reached * @throws IOException if other I/O error occurred */ static void readBytes(InputStream inputStream, byte[] buffer, int offset, int length) throws IOException { if (inputStream.read(buffer, offset, length) < length) { throw new EOFException(); } } }