code: public static InputStream convertOutputStreamToInputStream(OutputStream outputStream) {
      byte[] data = ((ByteArrayOutputStream) outputStream).toByteArray();
      return new ByteArrayInputStream(data);
    }
docs: Converts a {@link OutputStream} to an {@link InputStream} by coping the data directly.
  WARNING: Do not use for large data (>100MB). Only for testing purpose.
  
  @param outputStream the {@link OutputStream} to convert
  @return the resulting {@link InputStream}