Java InputStream Read Bytes readBytes(InputStream inputStream, byte[] buffer, int offset, int length)

Here you can find the source of readBytes(InputStream inputStream, byte[] buffer, int offset, int length)

Description

Reads a sequence of bytes from the input, raising an EOFException if end of stream is reached.

License

Open Source License

Parameter

Parameter Description
inputStream source input stream
buffer destination buffer
offset offset in the buffer
length number of bytes to read

Exception

Parameter Description
EOFException if end of stream reached
IOExceptionif other I/O error occurred

Declaration

static void readBytes(InputStream inputStream, byte[] buffer, int offset, int length) throws IOException 

Method Source Code


//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();
        }
    }
}

Related

  1. readBytes(InputStream inputStream)
  2. readBytes(InputStream inputStream)
  3. readBytes(InputStream inputStream)
  4. readBytes(InputStream inputStream)
  5. readBytes(InputStream inputStream, boolean close)
  6. readBytes(InputStream inputStream, int bufSize)
  7. readBytes(InputStream inputStream, int length)
  8. readBytes(InputStream inputStream, int numberOfBytes)
  9. readBytes(InputStream inputStream, int numberOfBytes)