List of usage examples for javax.imageio.stream ImageInputStream getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.apache.xmlgraphics.image.loader.util.ImageUtil.java
/** * Decorates an ImageInputStream so the flush*() methods are ignored and have no effect. * The decoration is implemented using a dynamic proxy. * @param in the ImageInputStream//from w ww .j a v a2 s . c om * @return the decorated ImageInputStream */ public static ImageInputStream ignoreFlushing(final ImageInputStream in) { return (ImageInputStream) Proxy.newProxyInstance(in.getClass().getClassLoader(), new Class[] { ImageInputStream.class }, new InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String methodName = method.getName(); //Ignore calls to flush*() if (!methodName.startsWith("flush")) { try { return method.invoke(in, args); } catch (InvocationTargetException ite) { throw ite.getCause(); } } else { return null; } } }); }