public static InputStream streamResetForReRead(InputStream stream, TemporaryResources tmp)
            throws IOException {
        // If re-readable, rewind to start
        if (stream instanceof RereadableInputStream) {
            ((RereadableInputStream) stream).rewind();
            return stream;
        }

        // File or Factory based?
        TikaInputStream tstream = (TikaInputStream) stream;
        if (tstream.getInputStreamFactory() != null) {
            // Just get a fresh one each time from the factory
            return TikaInputStream.get(tstream.getInputStreamFactory(), tmp);
        }

        // File based, reset stream to beginning of File
        tstream.reset();
        tstream.mark(-1);
        return tstream;
    }
Resets the given {@link TikaInputStream} (checked by
{@link #ensureStreamReReadable(InputStream, TemporaryResources, Metadata)})
so that it can be re-read again.
tika-core/src/main/java/org/apache/tika/utils/ParserUtils.java