Java InputStream Read Bytes readBytes(InputStream in, byte[] buffer)

Here you can find the source of readBytes(InputStream in, byte[] buffer)

Description

read Bytes

License

Open Source License

Declaration

public static byte[] readBytes(InputStream in, byte[] buffer) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class Main {
    public static byte[] readBytes(InputStream in, byte[] buffer) throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        int read;
        while (0 <= (read = in.read(buffer))) {
            out.write(buffer, 0, read);/*from  ww w . j av  a  2s  .c om*/
        }
        return out.toByteArray();
    }
}

Related

  1. readBytes(InputStream in)
  2. readBytes(InputStream in, boolean forceClose)
  3. readBytes(InputStream in, byte[] b)
  4. readBytes(InputStream in, byte[] buf, int length)
  5. readBytes(InputStream in, byte[] buffer, int maxBytesAtOnce)
  6. readBytes(InputStream in, byte[] data, int offset, int length)
  7. readBytes(InputStream in, int bufferSize, boolean forceClose)
  8. readBytes(InputStream in, int bytesToRead, byte[] buffer, int bufferOffset)