code: public static byte[] getBytes(final InputStream sourceInputStream) throws IOException {
  
      ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
      byte[] buffer = new byte[BUFFER_SIZE];
      for (int len = 0; (len = sourceInputStream.read(buffer)) != -1;) {
        byteArrayOutputStream.write(buffer, 0, len);
      }
      byte[] arrayOfByte = byteArrayOutputStream.toByteArray();
      return arrayOfByte;
    }
docs: Get bytes from given input stream.
  
  @param sourceInputStream Source inputStream object to be handled.
  @return bytes from given input stream.
  @throws IOException