public void interceptStream(int index, InputStream stream)
            throws GuacamoleException {

        // Log beginning of intercepted stream
        logger.debug("Intercepting input stream #{} of tunnel \"{}\".",
                index, getUUID());

        try {
            inputStreamFilter.interceptStream(index, new BufferedInputStream(stream));
        }

        // Log end of intercepted stream
        finally {
            logger.debug("Intercepted input stream #{} of tunnel \"{}\" ended.",
                    index, getUUID());
        }

    }
Intercept the given stream, continuously writing the contents of the
given InputStream as blobs. The stream will automatically end when
when the end of the InputStream is reached. If there is no such
stream, then the InputStream will be closed immediately. This function
will block until all data from the InputStream has been written to the
given stream.

@param index
    The index of the stream to intercept.

@param stream
    The InputStream to read all blobs data from.

@throws GuacamoleException
    If an error occurs while intercepting the stream, or if the stream
    itself reports an error.
guacamole/src/main/java/org/apache/guacamole/tunnel/StreamInterceptingTunnel.java