diff -r 62c7b10ce177 -r e5ec12a932da jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java --- a/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java Tue Feb 22 12:01:35 2011 -0800 +++ b/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java Tue Feb 22 15:34:17 2011 -0800 @@ -571,9 +571,9 @@ long newLastSyncTime = 0; try { newLastSyncTime = prefsFile.lastModified(); - FileInputStream fis = new FileInputStream(prefsFile); - XmlSupport.importMap(fis, m); - fis.close(); + try (FileInputStream fis = new FileInputStream(prefsFile)) { + XmlSupport.importMap(fis, m); + } } catch(Exception e) { if (e instanceof InvalidPreferencesFormatException) { getLogger().warning("Invalid preferences format in " @@ -618,9 +618,9 @@ if (!dir.exists() && !dir.mkdirs()) throw new BackingStoreException(dir + " create failed."); - FileOutputStream fos = new FileOutputStream(tmpFile); - XmlSupport.exportMap(fos, prefsCache); - fos.close(); + try (FileOutputStream fos = new FileOutputStream(tmpFile)) { + XmlSupport.exportMap(fos, prefsCache); + } if (!tmpFile.renameTo(prefsFile)) throw new BackingStoreException("Can't rename " + tmpFile + " to " + prefsFile);