Author: msahyoun
Date: Sun Mar 11 19:27:54 2018
New Revision: 1826456

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

Modified:
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java?rev=1826456&r1=1826455&r2=1826456&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java
 Sun Mar 11 19:27:54 2018
@@ -44,7 +44,6 @@ import org.apache.fontbox.ttf.TrueTypeCo
 import org.apache.fontbox.ttf.TrueTypeFont;
 import org.apache.fontbox.type1.Type1Font;
 import org.apache.fontbox.util.autodetect.FontFileFinder;
-import org.apache.pdfbox.io.IOUtils;
 import org.apache.pdfbox.util.Charsets;
 
 /**
@@ -290,21 +289,19 @@ final class FileSystemFontProvider exten
      */
     private void saveDiskCache()
     {
-        BufferedWriter writer = null;
         File file = null;
         try
         {
-            try
-            {
-                file = getDiskCacheFile();
-                writer = new BufferedWriter(new FileWriter(file));
-            }
-            catch (SecurityException e)
-            {
-                LOG.debug("Couldn't create writer for " + 
file.getAbsolutePath(), e);
-                return;
-            }
+            file = getDiskCacheFile();
+        }
+        catch (SecurityException e)
+        {
+            LOG.debug("Couldn't create writer for font cache file", e);
+            return;
+        }
 
+        try (BufferedWriter writer = new BufferedWriter(new FileWriter(file)))
+        {
             for (FSFontInfo fontInfo : fontInfoList)
             {
                 writer.write(fontInfo.postScriptName.trim());
@@ -361,10 +358,6 @@ final class FileSystemFontProvider exten
             LOG.warn("Installed fonts information will have to be reloaded for 
each start");
             LOG.warn("You can assign a directory to the 'pdfbox.fontcache' 
property");
         }
-        finally
-        {
-            IOUtils.closeQuietly(writer);
-        }
     }
 
     /**


Reply via email to