pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msahy...@apache.org
Subject svn commit: r1827629 - /pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java
Date Sat, 24 Mar 2018 08:26:03 GMT
Author: msahyoun
Date: Sat Mar 24 08:26:03 2018
New Revision: 1827629

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

Modified:
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java?rev=1827629&r1=1827628&r2=1827629&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java Sat Mar 24 08:26:03
2018
@@ -261,24 +261,11 @@ public final class ExtractText
                                     {
                                         System.err.println("  is PDF (size=" + file.getSize()
+ ")");
                                     }
-                                    InputStream fis = file.createInputStream();
-                                    PDDocument subDoc = null;
-                                    try 
-                                    {
-                                        subDoc = PDDocument.load(fis);
-                                    } 
-                                    finally 
-                                    {
-                                        fis.close();
-                                    }
-                                    try 
+                                    try (InputStream fis = file.createInputStream();
+                                        PDDocument subDoc = PDDocument.load(fis))
                                     {
                                         stripper.writeText( subDoc, output );
                                     } 
-                                    finally 
-                                    {
-                                        IOUtils.closeQuietly(subDoc);                   
                   
-                                    }
                                 }
                             } 
                         }



Mime
View raw message