Java ByteArrayOutputStream Write readAll(InputStream in)

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

Description

read All

License

Open Source License

Declaration

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

Method Source Code


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

import java.io.*;

public class Main {
    public static byte[] readAll(InputStream in) throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream(Math.max(512, in.available()));
        byte[] buffer = new byte[1024 * 4];
        int n;/*from   w  w  w .  j  a v  a2 s .c o m*/
        while ((n = in.read(buffer)) != -1) {
            out.write(buffer, 0, n);
        }
        out.flush();
        return out.toByteArray();
    }
}

Related

  1. readAll(InputStream in)
  2. readAll(InputStream in)
  3. readAll(InputStream in)
  4. readAll(InputStream in)
  5. readAll(InputStream in)
  6. readAll(InputStream inputStream)
  7. readAll(InputStream is)
  8. readAll(InputStream s)
  9. readAll(InputStream stream)