code: public static byte[] readStream(InputStream in) {
          if(in == null){
              return null;
          }
          ByteArrayOutputStream out = null;
          try {
              out = new ByteArrayOutputStream();
              byte[] buf = new byte[1024 * 8];
              int length = 0;
              while((length = in.read(buf)) != -1){
                  out.write(buf, 0, length);
              }
              return out.toByteArray();
  
          } catch (IOException e) {
              throw new IORuntimeException(e);
  
          } finally {
              closeQuietly(in);
              closeQuietly(out);
          }
      }
docs: Reads an InputStream into a byte array
  @param in the InputStream to read from
  
  @return a byte array red from the InputStream
  
  @throws IORuntimeException if some other I/O error occurs.