Java InputStream Copy copyStreamBytes(InputStream is)

Here you can find the source of copyStreamBytes(InputStream is)

Description

copy Stream Bytes

License

Open Source License

Declaration

static byte[] copyStreamBytes(InputStream is) throws IOException 

Method Source Code

//package com.java2s;
// License & terms of use: http://www.unicode.org/copyright.html#License

import java.io.ByteArrayOutputStream;

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

public class Main {
    static byte[] copyStreamBytes(InputStream is) throws IOException {
        byte[] buffer = new byte[1024];

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        int len;//from   w  ww  .j  a va2 s.  c  o m
        while ((len = is.read(buffer, 0, buffer.length)) >= 0) {
            bos.write(buffer, 0, len);
        }
        return bos.toByteArray();
    }
}

Related

  1. copyStream(InputStream iss)
  2. copyStream(Reader in, Writer out)
  3. copyStream(Reader in, Writer out)
  4. copyStream(Reader reader, Writer writer)
  5. copyStream(ZipInputStream in, ZipEntry entry)
  6. copyStreamToByteArray(InputStream in, byte[] dest, int off, int len)
  7. copyStreamToBytes(InputStream inputStream)
  8. copyStreamToString(InputStream input)
  9. copyStreamToString(InputStream input)