Here you can find the source of readBytes(InputStream in, int bytesToRead, byte[] buffer, int bufferOffset)
Parameter | Description |
---|---|
in | a parameter |
bytesToRead | a parameter |
buffer | a parameter |
bufferOffset | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static final void readBytes(InputStream in, int bytesToRead, byte[] buffer, int bufferOffset) throws IOException
//package com.java2s; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; public class Main { /**/*from www. j a v a2 s. co m*/ * Reads bytesToRead bytes from the stream. * * @param in * @param bytesToRead * @param buffer * @param bufferOffset * * @throws IOException */ public static final void readBytes(InputStream in, int bytesToRead, byte[] buffer, int bufferOffset) throws IOException { int bytesRead = 0; int read; do { read = in.read(buffer, bufferOffset + bytesRead, bytesToRead); bytesRead += read; bytesToRead -= read; } while ((bytesToRead > 0) && (read > 0)); } /** * Reads bytesToRead bytes from the stream. * * @param in * @param bytesToRead * @param buffer * @param bufferOffset * * @throws IOException */ public static final void readBytes(BufferedInputStream in, int bytesToRead, byte[] buffer, int bufferOffset) throws IOException { int bytesRead = 0; int read; do { read = in.read(buffer, bufferOffset + bytesRead, bytesToRead); bytesRead += read; bytesToRead -= read; } while ((bytesToRead > 0) && (read > 0)); } }