code: public void setInputStream(InputStream stream) {
          try {
              cachedInputStream = new ByteArrayOutputStream();
              IOUtils.copy(stream, cachedInputStream);
          } catch (IOException e) {
              LOG.error("Exception on writing InputStream.", e);
          }
      }
docs: Set the cachedInputStream as a copy of passed {@link InputStream}
  
  @param stream The {@link InputStream} to set (copy)