git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1608162 13f79535-47bb-0310-9956-ffa450edef68tags/fop-2_0
@@ -63,6 +63,7 @@ public class FontPatternExtractor { | |||
} | |||
ByteArrayInputStream bin = new ByteArrayInputStream(baout.toByteArray()); | |||
IOUtils.closeQuietly(baout); | |||
DataInputStream din = new DataInputStream(bin); | |||
long len = din.readInt() & 0xFFFFFFFFL; | |||
println("Length: " + len); |
@@ -21,10 +21,11 @@ package org.apache.fop.afp.goca; | |||
import java.awt.Color; | |||
import java.awt.color.ColorSpace; | |||
import java.io.DataOutput; | |||
import java.io.DataOutputStream; | |||
import java.io.IOException; | |||
import java.io.OutputStream; | |||
import org.apache.commons.io.IOUtils; | |||
import org.apache.commons.io.output.ByteArrayOutputStream; | |||
import org.apache.xmlgraphics.java2d.color.CIELabColorSpace; | |||
@@ -105,6 +106,7 @@ public class GraphicsSetProcessColor extends AbstractGraphicsDrawingOrder { | |||
ColorSpace cs = color.getColorSpace(); | |||
int colSpaceType = cs.getType(); | |||
ByteArrayOutputStream baout = new ByteArrayOutputStream(); | |||
DataOutputStream dout = null; | |||
byte[] colsizes; | |||
if (colSpaceType == ColorSpace.TYPE_CMYK) { | |||
colspace = CMYK; | |||
@@ -121,7 +123,7 @@ public class GraphicsSetProcessColor extends AbstractGraphicsDrawingOrder { | |||
} else if (cs instanceof CIELabColorSpace) { | |||
colspace = CIELAB; | |||
colsizes = new byte[] {0x08, 0x08, 0x08, 0x00}; | |||
DataOutput dout = new java.io.DataOutputStream(baout); | |||
dout = new DataOutputStream(baout); | |||
//According to GOCA, I'd expect the multiplicator below to be 255f, not 100f | |||
//But only IBM AFP Workbench seems to support Lab colors and it requires "c * 100f" | |||
int l = Math.round(colorComponents[0] * 100f); | |||
@@ -131,6 +133,8 @@ public class GraphicsSetProcessColor extends AbstractGraphicsDrawingOrder { | |||
dout.writeByte(a); | |||
dout.writeByte(b); | |||
} else { | |||
IOUtils.closeQuietly(dout); | |||
IOUtils.closeQuietly(baout); | |||
throw new IllegalStateException(); | |||
} | |||
@@ -151,6 +155,8 @@ public class GraphicsSetProcessColor extends AbstractGraphicsDrawingOrder { | |||
os.write(data); | |||
baout.writeTo(os); | |||
IOUtils.closeQuietly(dout); | |||
IOUtils.closeQuietly(baout); | |||
} | |||
/** {@inheritDoc} */ |
@@ -85,6 +85,7 @@ public class PFMFile { | |||
short sh2 = in.readByte(); | |||
if (sh1 == 128 && sh2 == 1) { | |||
//Found the first section header of a PFB file! | |||
IOUtils.closeQuietly(in); | |||
throw new IOException("Cannot parse PFM file. You probably specified the PFB file" | |||
+ " of a Type 1 font as parameter instead of the PFM."); | |||
} | |||
@@ -93,6 +94,7 @@ public class PFMFile { | |||
bufin.read(b); | |||
if (new String(b, "US-ASCII").equalsIgnoreCase("StartFontMetrics")) { | |||
//Found the header of a AFM file! | |||
IOUtils.closeQuietly(in); | |||
throw new IOException("Cannot parse PFM file. You probably specified the AFM file" | |||
+ " of a Type 1 font as parameter instead of the PFM."); | |||
} |
@@ -36,6 +36,8 @@ import java.util.List; | |||
import org.xml.sax.InputSource; | |||
import org.apache.commons.io.IOUtils; | |||
/** | |||
* <p>This tree structure stores the hyphenation patterns in an efficient | |||
* way for fast lookup. It provides the provides the method to | |||
@@ -709,9 +711,9 @@ public class HyphenationTree extends TernaryTree | |||
token = in.readLine().trim(); | |||
long starttime = 0; | |||
int counter = 0; | |||
BufferedReader reader = null; | |||
try { | |||
BufferedReader reader | |||
= new BufferedReader(new FileReader(token)); | |||
reader = new BufferedReader(new FileReader(token)); | |||
String line; | |||
starttime = System.currentTimeMillis(); | |||
@@ -731,6 +733,8 @@ public class HyphenationTree extends TernaryTree | |||
} catch (Exception ioe) { | |||
System.out.println("Exception " + ioe); | |||
ioe.printStackTrace(); | |||
} finally { | |||
IOUtils.closeQuietly(reader); | |||
} | |||
long endtime = System.currentTimeMillis(); | |||
long result = endtime - starttime; |
@@ -97,6 +97,7 @@ public class PreloaderWMF extends AbstractImagePreloader { | |||
int magic = EndianUtils.swapInteger(din.readInt()); | |||
din.reset(); | |||
if (magic != WMFConstants.META_ALDUS_APM) { | |||
IOUtils.closeQuietly(din); | |||
return null; //Not a WMF file | |||
} | |||
@@ -1587,6 +1587,8 @@ public class PDFFactory { | |||
log.error( | |||
"Failed to write CIDSet [" + cidFont + "] " | |||
+ cidFont.getEmbedFontName(), ioe); | |||
} finally { | |||
IOUtils.closeQuietly(baout); | |||
} | |||
} | |||
@@ -21,6 +21,7 @@ package org.apache.fop.pdf; | |||
import java.io.IOException; | |||
import org.apache.commons.io.IOUtils; | |||
import org.apache.commons.io.output.ByteArrayOutputStream; | |||
/** | |||
@@ -167,7 +168,9 @@ public class PDFOutputIntent extends PDFObject { | |||
} catch (IOException ioe) { | |||
log.error("Ignored I/O exception", ioe); | |||
} | |||
return bout.toByteArray(); | |||
byte[] bytes = bout.toByteArray(); | |||
IOUtils.closeQuietly(bout); | |||
return bytes; | |||
} | |||
@@ -42,6 +42,7 @@ import java.text.DecimalFormat; | |||
import java.text.DecimalFormatSymbols; | |||
import java.util.Locale; | |||
import org.apache.commons.io.IOUtils; | |||
import org.apache.commons.io.output.ByteArrayOutputStream; | |||
import org.apache.xmlgraphics.image.GraphicsUtil; | |||
@@ -447,6 +448,8 @@ public class PCLGenerator { | |||
writeCommand("*c" + patternID + "G"); | |||
writeCommand("*c" + baout.size() + "W"); | |||
baout.writeTo(this.out); | |||
IOUtils.closeQuietly(data); | |||
IOUtils.closeQuietly(baout); | |||
writeCommand("*c4Q"); //temporary pattern | |||
} | |||
@@ -26,6 +26,7 @@ import java.awt.image.Raster; | |||
import java.io.IOException; | |||
import java.util.Arrays; | |||
import org.apache.commons.io.IOUtils; | |||
import org.apache.commons.io.output.ByteArrayOutputStream; | |||
import org.apache.commons.logging.Log; | |||
import org.apache.commons.logging.LogFactory; | |||
@@ -241,12 +242,12 @@ public abstract class AbstractImageAdapter implements PDFImage { | |||
+ " The image may not be handled correctly." + " Base color space: " | |||
+ icm.getColorSpace() + " Image: " + image.getInfo()); | |||
} | |||
ByteArrayOutputStream baout = new ByteArrayOutputStream(); | |||
int c = icm.getMapSize(); | |||
int hival = c - 1; | |||
if (hival > MAX_HIVAL) { | |||
throw new UnsupportedOperationException("hival must not go beyond " + MAX_HIVAL); | |||
} | |||
ByteArrayOutputStream baout = new ByteArrayOutputStream(); | |||
boolean isDeviceGray = false; | |||
int[] palette = new int[c]; | |||
icm.getRGBs(palette); | |||
@@ -276,6 +277,7 @@ public abstract class AbstractImageAdapter implements PDFImage { | |||
indexed.add(hival); | |||
indexed.add(baout.toByteArray()); | |||
IOUtils.closeQuietly(baout); | |||
dict.put("ColorSpace", indexed); | |||
@@ -28,6 +28,7 @@ import java.util.Date; | |||
import java.util.List; | |||
import java.util.StringTokenizer; | |||
import org.apache.commons.io.IOUtils; | |||
import org.apache.tools.ant.BuildException; | |||
/** | |||
@@ -98,6 +99,7 @@ public class FileCompare { | |||
* @return true if files are same byte-by-byte, false otherwise | |||
*/ | |||
private static boolean compareBytes(File file1, File file2) throws IOException { | |||
boolean same = true; | |||
BufferedInputStream file1Input | |||
= new BufferedInputStream(new java.io.FileInputStream(file1)); | |||
BufferedInputStream file2Input | |||
@@ -111,11 +113,15 @@ public class FileCompare { | |||
charact1 = file1Input.read(); | |||
charact2 = file2Input.read(); | |||
} else { | |||
return false; | |||
same = false; | |||
break; | |||
} | |||
} | |||
return true; | |||
IOUtils.closeQuietly(file1Input); | |||
IOUtils.closeQuietly(file2Input); | |||
return same; | |||
} | |||
/** |