Java InputStream Read getInputStreamToBytes(InputStream is)

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

Description

get Input Stream To Bytes

License

Open Source License

Declaration

static byte[] getInputStreamToBytes(InputStream is) 

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 {
    static byte[] getInputStreamToBytes(InputStream is) {
        int read = 0;
        byte[] bytes = new byte[1024 * 1024 * 2];
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        try {//from w ww.jav  a  2 s .c o  m
            while ((read = is.read(bytes)) != -1)
                bos.write(bytes, 0, read);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return bos.toByteArray();
    }
}

Related

  1. getInputStreamFromZip(ZipInputStream zis, String filename)
  2. getInputStreamLength(InputStream in)
  3. getInputStreamReader(InputStream in, String charset)
  4. getInputStreamReaderAsResource(Class clazz, String fileName)
  5. getInputStreamString(final InputStream in)
  6. inputStreamReadBytesUntil(int endInd, InputStream is, byte[] buf, int off)
  7. inputStreamToList(InputStream stream)