List of usage examples for javax.imageio.stream ImageInputStream getStreamPosition
long getStreamPosition() throws IOException;
From source file:org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.java
/** {@inheritDoc} */ public void returnSource(String uri, Source src) { //Safety check to make sure the Preloaders behave ImageInputStream in = ImageUtil.getImageInputStream(src); try {/*from w ww . j a v a2 s . c o m*/ if (in != null && in.getStreamPosition() != 0) { throw new IllegalStateException("ImageInputStream is not reset for: " + uri); } } catch (IOException ioe) { //Ignore exception ImageUtil.closeQuietly(src); } if (isReusable(src)) { //Only return the Source if it's reusable log.debug("Returning Source for " + uri); sessionSources.put(uri, src); } else { //Otherwise, try to close if possible and forget about it ImageUtil.closeQuietly(src); } }