Java ByteArrayOutputStream Write readAll(InputStream in)

Here you can find the source of readAll(InputStream in)

Description

read All

License

Apache License

Declaration

private static byte[] readAll(InputStream in) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.ByteArrayOutputStream;

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

public class Main {
    private static byte[] readAll(InputStream in) throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        byte[] buffer = new byte[8192];

        int bytesRead = 0;
        while ((bytesRead = in.read(buffer)) > 0) {
            out.write(buffer, 0, bytesRead);
        }/*from w  w w . j a  v a2 s  .  c o m*/

        return out.toByteArray();
    }
}

Related

  1. readAll(InputStream aInputStream)
  2. readAll(InputStream bytes)
  3. readAll(InputStream bytes, int bufferSize)
  4. readAll(InputStream in)
  5. readAll(InputStream in)
  6. readAll(InputStream in)
  7. readAll(InputStream in)
  8. readAll(InputStream in)
  9. readAll(InputStream in)