Here you can find the source of getInputStreamToBytes(InputStream is)
static byte[] getInputStreamToBytes(InputStream is)
//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(); } }