public long getLength() throws IOException {
        if (length == -1) {
            getPath(); // updates length internally
        }
        return length;
    }
Returns the length (in bytes) of this stream. Note that if the length
was not available when this stream was instantiated, then this method
will use the {@link #getPath()} method to buffer the entire stream to
a temporary file in order to calculate the stream length. This case
will only work if the stream has not yet been consumed.

@return stream length
@throws IOException if the length can not be determined
tika-core/src/main/java/org/apache/tika/io/TikaInputStream.java