예제 #1
0
  public BufferedImage decodeAsBufferedImage(InputStream input) throws Exception {
    if (jpegCodecClazz == null) {
      jpegCodecClazz = Class.forName("com.sun.image.codec.jpeg.JPEGCodec");
    }

    Object decoder = MethodUtils.invokeStaticMethod(jpegCodecClazz, "createJPEGDecoder", input);

    return (BufferedImage) MethodUtils.invokeMethod(decoder, "decodeAsBufferedImage", null);
  }
 /** Invoke the static method. */
 public static Object invokeStaticMethod(Class<?> cls, String methodName, Object[] arguments)
     throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
   return MethodUtils.invokeStaticMethod(cls, methodName, arguments);
 }