public static byte[] toByteArray(InputStream input) throws IOException {
  ByteArrayOutputStream output=new ByteArrayOutputStream();
  stream(input,output);
  return output.toByteArray();
}

public static byte [ ] toByteArray ( InputStream input ) throws IOException { ByteArrayOutputStream output = new ByteArrayOutputStream ( ) ; stream ( input , output ) ; return output . toByteArray ( ) ; }
read the given input stream into a byte array . the given input stream will implicitly be closed after streaming , regardless of whether an exception is been thrown or not .
