public static SeekableStream wrapInputStream(InputStream is,
                                                 boolean canSeekBackwards) {
        SeekableStream stream = null;

        if (canSeekBackwards) {
            try {
                stream = new FileCacheSeekableStream(is);
            } catch (Exception e) {
                stream = new MemoryCacheSeekableStream(is);
            }
        } else {
            stream = new ForwardSeekableStream(is);
        }
        return stream;
    }
Returns a <code>SeekableStream</code> that will read from a
given <code>InputStream</code>, optionally including support
for seeking backwards.  This is a convenience method that
avoids the need to instantiate specific subclasses of
<code>SeekableStream</code> depending on the current security
model.

@param is An <code>InputStream</code>.
@param canSeekBackwards <code>true</code> if the ability to seek
       backwards in the output is required.
@return An instance of <code>SeekableStream</code>.
plugins/svg-plugin/batik-codec-fix/src/main/java/org/apache/batik/ext/awt/image/codec/util/SeekableStream.java