Here you can find the source of getBytes2(InputStream aStream)
public static byte[] getBytes2(InputStream aStream) throws IOException
//package com.java2s; import java.io.*; public class Main { /**/*from ww w . jav a 2 s. c o m*/ * Returns bytes for an input stream. */ public static byte[] getBytes2(InputStream aStream) throws IOException { ByteArrayOutputStream bs = new ByteArrayOutputStream(); byte chunk[] = new byte[8192]; for (int len = aStream.read(chunk, 0, chunk.length); len > 0; len = aStream.read(chunk, 0, chunk.length)) bs.write(chunk, 0, len); return bs.toByteArray(); } }