pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1804017 - /pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PDFHighlighter.java
Date Thu, 03 Aug 2017 16:44:54 GMT
Author: tilman
Date: Thu Aug  3 16:44:54 2017
New Revision: 1804017

URL: http://svn.apache.org/viewvc?rev=1804017&view=rev
Log:
PDFBOX-2852: use jdk7 syntax

Modified:
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PDFHighlighter.java

Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PDFHighlighter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PDFHighlighter.java?rev=1804017&r1=1804016&r2=1804017&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PDFHighlighter.java
(original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PDFHighlighter.java
Thu Aug  3 16:44:54 2017
@@ -140,29 +140,19 @@ public class PDFHighlighter extends PDFT
     public static void main(String[] args) throws IOException
     {
         PDFHighlighter xmlExtractor = new PDFHighlighter();
-        PDDocument doc = null;
-        try
+        if (args.length < 2)
+        {
+            usage();
+        }
+        String[] highlightStrings = new String[args.length - 1];
+        System.arraycopy(args, 1, highlightStrings, 0, highlightStrings.length);
+        try (PDDocument doc = PDDocument.load(new File(args[0])))
         {
-            if( args.length < 2 )
-            {
-                usage();
-            }
-            String[] highlightStrings = new String[ args.length - 1];
-            System.arraycopy( args, 1, highlightStrings, 0, highlightStrings.length );
-            doc = PDDocument.load( new File(args[0]) );
-
             xmlExtractor.generateXMLHighlight(
                 doc,
                 highlightStrings,
                 new OutputStreamWriter( System.out ) );
         }
-        finally
-        {
-            if( doc != null )
-            {
-                doc.close();
-            }
-        }
     }
 
     private static void usage()



Mime
View raw message