pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1791396 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/JPXFilter.java
Date Fri, 14 Apr 2017 19:21:25 GMT
Author: tilman
Date: Fri Apr 14 19:21:25 2017
New Revision: 1791396

URL: http://svn.apache.org/viewvc?rev=1791396&view=rev
Log:
PDFBOX-2852: simplify code, use JDK7 syntax

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/JPXFilter.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/JPXFilter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/JPXFilter.java?rev=1791396&r1=1791395&r2=1791396&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/JPXFilter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/JPXFilter.java Fri Apr 14 19:21:25
2017
@@ -66,11 +66,8 @@ public final class JPXFilter extends Fil
 
             case DataBuffer.TYPE_USHORT:
                 DataBufferUShort wordBuffer = (DataBufferUShort) raster.getDataBuffer();
-                int size = wordBuffer.getSize();
-                short[] data = wordBuffer.getData();
-                for (int i = 0; i < size; ++i)
+                for (short w : wordBuffer.getData())
                 {
-                    short w = data[i];
                     decoded.write(w >> 8);
                     decoded.write(w);
                 }
@@ -85,10 +82,8 @@ public final class JPXFilter extends Fil
     private BufferedImage readJPX(InputStream input, DecodeResult result) throws IOException
     {
         ImageReader reader = findImageReader("JPEG2000", "Java Advanced Imaging (JAI) Image
I/O Tools are not installed");
-        ImageInputStream iis = null;
-        try
+        try (ImageInputStream iis = ImageIO.createImageInputStream(input))
         {
-            iis = ImageIO.createImageInputStream(input);
             reader.setInput(iis, true, true);
 
             BufferedImage image;
@@ -131,10 +126,6 @@ public final class JPXFilter extends Fil
         }
         finally
         {
-            if (iis != null)
-            {
-                iis.close();
-            }
             reader.dispose();
         }
     }



Mime
View raw message