Java InputStream Read Bytes readBytes(InputStream inputStream)

Here you can find the source of readBytes(InputStream inputStream)

Description

read Bytes

License

Open Source License

Declaration

public static byte[] readBytes(InputStream inputStream)
            throws IOException 

Method Source Code

//package com.java2s;
// under the terms of the Eclipse Public License v1.0 which accompanies

import java.io.BufferedInputStream;

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

public class Main {
    public static byte[] readBytes(InputStream inputStream)
            throws IOException {
        BufferedInputStream bufferedInputStream = new BufferedInputStream(
                inputStream);//from   www  .j  a va  2  s  . c  o m
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        byte[] array = new byte[1024];
        while (true) {
            int len = bufferedInputStream.read(array);
            if (len == -1) {
                break;
            }
            output.write(array, 0, len);
        }
        return output.toByteArray();
    }
}

Related

  1. readBytes(InputStream inputStream)
  2. readBytes(InputStream inputStream)
  3. readBytes(InputStream inputStream)
  4. readBytes(InputStream inputStream)
  5. readBytes(InputStream inputStream)
  6. readBytes(InputStream inputStream)
  7. readBytes(InputStream inputStream)
  8. readBytes(InputStream inputStream, boolean close)
  9. readBytes(InputStream inputStream, byte[] buffer, int offset, int length)