pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1837549 - /pdfbox/trunk/tools/src/test/java/org/apache/pdfbox/tools/imageio/TestImageIOUtils.java
Date Mon, 06 Aug 2018 19:02:38 GMT
Author: tilman
Date: Mon Aug  6 19:02:38 2018
New Revision: 1837549

URL: http://svn.apache.org/viewvc?rev=1837549&view=rev
Log:
PDFBOX-4285: use try-with-resources

Modified:
    pdfbox/trunk/tools/src/test/java/org/apache/pdfbox/tools/imageio/TestImageIOUtils.java

Modified: pdfbox/trunk/tools/src/test/java/org/apache/pdfbox/tools/imageio/TestImageIOUtils.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/test/java/org/apache/pdfbox/tools/imageio/TestImageIOUtils.java?rev=1837549&r1=1837548&r2=1837549&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/test/java/org/apache/pdfbox/tools/imageio/TestImageIOUtils.java
(original)
+++ pdfbox/trunk/tools/src/test/java/org/apache/pdfbox/tools/imageio/TestImageIOUtils.java
Mon Aug  6 19:02:38 2018
@@ -257,10 +257,13 @@ public class TestImageIOUtils extends Te
         String fileName = outputPrefix + 1;
         LOG.info("Writing: " + fileName + "." + imageFormat);
         System.out.println("  " + fileName + "." + imageFormat); // for Maven (keep me!)
-        OutputStream os = new FileOutputStream(fileName + "." + imageFormat);
-        boolean res = ImageIOUtil.writeImage(image, imageFormat, os, Math.round(dpi), compressionQuality,
compressionType);
-        os.close();
-        assertTrue("ImageIOUtil.writeImage() failed for file " + fileName, res);
+        try (OutputStream os = new FileOutputStream(fileName + "." + imageFormat))
+        {
+            boolean res = ImageIOUtil.writeImage(image, imageFormat, os,
+                    Math.round(dpi), compressionQuality, compressionType);
+            assertTrue("ImageIOUtil.writeImage() failed for file " + fileName, res);
+        }
+        
         if ("jpg".equals(imageFormat) || "gif".equals(imageFormat) || "JPEG".equals(compressionType))
         {
             // jpeg is lossy, gif has 256 colors, 



Mime
View raw message