// ImageIO
import javax.imageio.ImageIO;
+import org.apache.commons.io.IOUtils;
+
/**
* FopImage object using ImageIO.
* @see AbstractFopImage
} catch (Exception ex) {
log.error("Error while loading image: " + ex.getMessage(), ex);
return false;
+ } finally {
+ IOUtils.closeQuietly(inputStream);
+ inputStream = null;
}
return true;
}
import org.apache.batik.ext.awt.image.codec.FileCacheSeekableStream;
import org.apache.batik.ext.awt.image.rendered.Any2sRGBRed;
import org.apache.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.commons.io.IOUtils;
/**
* FopImage object using TIFF
}
} catch (IOException ioe) {
log.error("Error while loading image (Batik): " + ioe.getMessage(), ioe);
- try {
- seekableInput.close();
- } catch (IOException ioex) {
- // ignore
- }
- try {
- inputStream.close();
- } catch (IOException ioex) {
- // ignore
- }
+ IOUtils.closeQuietly(seekableInput);
+ IOUtils.closeQuietly(inputStream);
seekableInput = null;
inputStream = null;
return false;
log.error("Error while loading image (Batik): " + ex.getMessage(), ex);
} finally {
// Make sure we clean up
- try {
- seekableInput.close();
- } catch (IOException ioex) {
- // ignore
- }
- try {
- inputStream.close();
- } catch (IOException ioex) {
- // ignore
- }
+ IOUtils.closeQuietly(seekableInput);
+ IOUtils.closeQuietly(inputStream);
seekableInput = null;
inputStream = null;
cr = null;
import java.io.IOException;
import java.awt.color.ColorSpace;
+import org.apache.commons.io.IOUtils;
+
/**
* Bitmap image.
* This supports loading a bitmap image into bitmap data.
}
} catch (IOException ex) {
log.error("Error while loading image (Bmp): " + ex.getMessage(), ex);
- try {
- inputStream.close();
- } catch (java.io.IOException ioe) {
- // Ignore
- }
+ IOUtils.closeQuietly(inputStream);
inputStream = null;
return false;
}
log.error("Error while loading image (Bmp): " + ex.getMessage(), ex);
return false;
} finally {
- try {
- inputStream.close();
- } catch (java.io.IOException ioe) {
- // Ignore
- }
+ IOUtils.closeQuietly(inputStream);
inputStream = null;
}
import java.io.IOException;
import java.net.URLConnection;
+import org.apache.commons.io.IOUtils;
+
/**
* FopImage object for GIF images, using Java native classes.
* @author Eric SCHAEFFER
log.error("Error while loading image (Gif): " + ex.getMessage(), ex);
return false;
} finally {
- try {
- inputStream.close();
- } catch (java.io.IOException ioe) {
- // Ignore
- }
+ IOUtils.closeQuietly(inputStream);
inputStream = null;
}
// JAI
import javax.media.jai.JAI;
import javax.media.jai.RenderedOp;
+
+import org.apache.commons.io.IOUtils;
// Sun codec
import com.sun.media.jai.codec.FileCacheSeekableStream;
} catch (Exception ex) {
log.error("Error while loading image (JAI): " + ex.getMessage(), ex);
} finally {
- try {
- inputStream.close();
- } catch (java.io.IOException ioe) {
- // Ignore
- }
+ IOUtils.closeQuietly(inputStream);
inputStream = null;
if (seekableInput != null) {
- try {
- seekableInput.close();
- } catch (java.io.IOException ioe) {
- // Ignore
- }
+ IOUtils.closeQuietly(seekableInput);
}
}
}
import java.awt.color.ColorSpace;
import java.awt.Color;
+import org.apache.commons.io.IOUtils;
+
// Jimi
import com.sun.jimi.core.Jimi;
log.error("Error while loading image (Jimi): " + ex.getMessage(), ex);
return;
} finally {
- try {
- inputStream.close();
- } catch (java.io.IOException ioe) {
- // Ignore
- }
+ IOUtils.closeQuietly(inputStream);
inputStream = null;
}
import java.awt.color.ICC_Profile;
// FOP
+import org.apache.commons.io.IOUtils;
import org.apache.fop.util.CMYKColorSpace;
/**
log.error("Error while loading image (Jpeg): " + ex.getMessage(), ex);
return false;
} finally {
- try {
- inputStream.close();
- } catch (java.io.IOException ioe) {
- // Ignore
- }
+ IOUtils.closeQuietly(inputStream);
inputStream = null;
}
import org.apache.batik.ext.awt.image.codec.tiff.TIFFField;
import org.apache.batik.ext.awt.image.codec.tiff.TIFFImageDecoder;
import org.apache.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.commons.io.IOUtils;
/**
* TIFF implementation using the Batik codecs.
log.error("Error while loading image strip 1 (TIFF): ", ioe);
return false;
} finally {
- try {
- this.seekableInput.close();
- } catch (IOException ioex) {
- // ignore
- }
- try {
- this.inputStream.close();
- } catch (IOException ioex) {
- // ignore
- }
+ IOUtils.closeQuietly(seekableInput);
+ IOUtils.closeQuietly(inputStream);
this.seekableInput = null;
this.inputStream = null;
this.cr = null;
import java.io.IOException;
// FOP
+import org.apache.commons.io.IOUtils;
import org.apache.fop.image.FopImage;
import org.apache.fop.image.EPSImage;
import org.apache.fop.apps.FOUserAgent;
info.height = (int) (data.bbox[3] - data.bbox[1]);
// image data read
- bis.close();
+ IOUtils.closeQuietly(bis);
info.inputStream = null;
return info;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.UnitProcessor;
import org.apache.batik.dom.svg.SVGDOMImplementation;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
FOUserAgent ua) throws IOException {
FopImage.ImageInfo info = loadImage(uri, fis, ua);
if (info != null) {
- try {
- fis.close();
- } catch (Exception e) {
- //ignore
- }
+ IOUtils.closeQuietly(fis);
}
return info;
}
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.apache.fop.apps.FOUserAgent;
// Commons-Logging
+import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
throws IOException {
FopImage.ImageInfo info = loadImage(uri, fis, ua);
if (info != null) {
- try {
- fis.close();
- } catch (Exception e) {
- //ignore
- }
+ IOUtils.closeQuietly(fis);
}
return info;
}