jeremias    2003/11/08 06:19:45

  Modified:    src/java/org/apache/fop/render/rtf/rtflib/rtfdoc
                        RtfExternalGraphic.java
  Log:
  Changed image loading to use Commons IO.
  Properly close InputStream.
  
  Revision  Changes    Path
  1.3       +9 -16     
xml-fop/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java
  
  Index: RtfExternalGraphic.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RtfExternalGraphic.java   8 Nov 2003 14:01:23 -0000       1.2
  +++ RtfExternalGraphic.java   8 Nov 2003 14:19:45 -0000       1.3
  @@ -58,15 +58,14 @@
   
   package org.apache.fop.render.rtf.rtflib.rtfdoc;
   
  +import org.apache.commons.io.IOUtil;
   import org.apache.fop.render.rtf.rtflib.tools.ImageConstants;
   import org.apache.fop.render.rtf.rtflib.tools.ImageUtil;
   //import org.apache.fop.render.rtf.rtflib.tools.jpeg.Encoder;
   //import org.apache.fop.render.rtf.rtflib.tools.jpeg.JPEGException;
   
  -import java.io.BufferedInputStream;
  -
  -import java.io.ByteArrayOutputStream;
   import java.io.IOException;
  +import java.io.InputStream;
   import java.io.Writer;
   
   import java.io.File;
  @@ -247,18 +246,12 @@
   
           data = null;
           try {
  -            // image reading patch provided by Michael Krause <[EMAIL PROTECTED]>
  -            final BufferedInputStream bin = new 
BufferedInputStream(url.openStream());
  -            final ByteArrayOutputStream bout = new ByteArrayOutputStream();
  -            while (true) {
  -                final int datum = bin.read();
  -                if (datum == -1) {
  -                   break;
  -                }
  -                bout.write(datum);
  -             }
  -             bout.flush();
  -             data = bout.toByteArray();
  +            final InputStream in = url.openStream();
  +            try {
  +                data = IOUtil.toByteArray(url.openStream());
  +            } finally {
  +                IOUtil.shutdownStream(in);
  +            }
           } catch (Exception e) {
               throw new ExternalGraphicException("The attribute 'src' of "
                       + "<fo:external-graphic> has a invalid value: '"
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to