Index: trunk/src/org/openstreetmap/josm/plugins/Plugin.java
===================================================================
--- trunk/src/org/openstreetmap/josm/plugins/Plugin.java	(revision 7025)
+++ trunk/src/org/openstreetmap/josm/plugins/Plugin.java	(revision 7033)
@@ -110,9 +110,8 @@
             pluginDir.mkdirs();
         }
-        FileOutputStream out = null;
-        InputStream in = null;
-        try {
-            out = new FileOutputStream(new File(pluginDirName, to));
-            in = getClass().getResourceAsStream(from);
+        try (
+            FileOutputStream out = new FileOutputStream(new File(pluginDirName, to));
+            InputStream in = getClass().getResourceAsStream(from)
+        ) {
             if (in == null) {
                 throw new IOException("Resource not found: "+from);
@@ -122,7 +121,4 @@
                 out.write(buffer, 0, len);
             }
-        } finally {
-            Utils.close(in);
-            Utils.close(out);
         }
     }
Index: trunk/src/org/openstreetmap/josm/plugins/PluginDownloadTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/plugins/PluginDownloadTask.java	(revision 7025)
+++ trunk/src/org/openstreetmap/josm/plugins/PluginDownloadTask.java	(revision 7033)
@@ -24,5 +24,4 @@
 import org.openstreetmap.josm.io.MirroredInputStream;
 import org.openstreetmap.josm.tools.CheckParameterUtil;
-import org.openstreetmap.josm.tools.Utils;
 import org.xml.sax.SAXException;
 
@@ -118,6 +117,4 @@
                 throw new PluginDownloadException(tr("Download skipped"));
         }
-        OutputStream out = null;
-        InputStream in = null;
         try {
             if (pi.downloadlink == null) {
@@ -130,9 +127,12 @@
                 downloadConnection = MirroredInputStream.connectFollowingRedirect(url, PLUGIN_MIME_TYPES);
             }
-            in = downloadConnection.getInputStream();
-            out = new FileOutputStream(file);
-            byte[] buffer = new byte[8192];
-            for (int read = in.read(buffer); read != -1; read = in.read(buffer)) {
-                out.write(buffer, 0, read);
+            try (
+                InputStream in = downloadConnection.getInputStream();
+                OutputStream out = new FileOutputStream(file)
+            ) {
+                byte[] buffer = new byte[8192];
+                for (int read = in.read(buffer); read != -1; read = in.read(buffer)) {
+                    out.write(buffer, 0, read);
+                }
             }
         } catch (MalformedURLException e) {
@@ -145,9 +145,7 @@
             throw new PluginDownloadException(e);
         } finally {
-            Utils.close(in);
             synchronized(this) {
                 downloadConnection = null;
             }
-            Utils.close(out);
         }
     }
Index: trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
===================================================================
--- trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java	(revision 7025)
+++ trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java	(revision 7033)
@@ -107,9 +107,8 @@
         this.name = name;
         this.file = file;
-        FileInputStream fis = null;
-        JarInputStream jar = null;
-        try {
-            fis = new FileInputStream(file);
-            jar = new JarInputStream(fis);
+        try (
+            FileInputStream fis = new FileInputStream(file);
+            JarInputStream jar = new JarInputStream(fis)
+        ) {
             Manifest manifest = jar.getManifest();
             if (manifest == null)
@@ -119,7 +118,4 @@
         } catch (IOException e) {
             throw new PluginException(name, e);
-        } finally {
-            Utils.close(jar);
-            Utils.close(fis);
         }
     }
@@ -380,7 +376,11 @@
         String name = pluginName;
         name = name.replaceAll("[-. ]", "");
-        InputStream manifestStream = PluginInformation.class.getResourceAsStream("/org/openstreetmap/josm/plugins/"+name+"/MANIFEST.MF");
-        if (manifestStream != null)
-            return new PluginInformation(manifestStream, pluginName, null);
+        try (InputStream manifestStream = PluginInformation.class.getResourceAsStream("/org/openstreetmap/josm/plugins/"+name+"/MANIFEST.MF")) {
+            if (manifestStream != null) {
+                return new PluginInformation(manifestStream, pluginName, null);
+            }
+        } catch (IOException e) {
+            Main.warn(e);
+        }
 
         Collection<String> locations = getPluginLocations();
Index: trunk/src/org/openstreetmap/josm/plugins/ReadLocalPluginInformationTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/plugins/ReadLocalPluginInformationTask.java	(revision 7025)
+++ trunk/src/org/openstreetmap/josm/plugins/ReadLocalPluginInformationTask.java	(revision 7033)
@@ -172,7 +172,5 @@
 
     protected void processLocalPluginInformationFile(File file) throws PluginListParseException{
-        FileInputStream fin = null;
-        try {
-            fin = new FileInputStream(file);
+        try (FileInputStream fin = new FileInputStream(file)) {
             List<PluginInformation> pis = new PluginListParser().parse(fin);
             for (PluginInformation pi : pis) {
@@ -185,6 +183,4 @@
         } catch(IOException e) {
             throw new PluginListParseException(e);
-        } finally {
-            Utils.close(fin);
         }
     }
Index: trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java	(revision 7025)
+++ trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java	(revision 7033)
@@ -203,20 +203,23 @@
 
     private void handleIOException(final ProgressMonitor monitor, IOException e, final String title, final String firstMessage, boolean displayMsg) {
-        InputStream errStream = connection.getErrorStream();
         StringBuilder sb = new StringBuilder();
-        if (errStream != null) {
-            BufferedReader err = null;
-            try {
-                String line;
-                err = new BufferedReader(new InputStreamReader(errStream, Utils.UTF_8));
-                while ((line = err.readLine()) != null) {
-                    sb.append(line).append("\n");
-                }
-            } catch (Exception ex) {
-                Main.error(e);
-                Main.error(ex);
-            } finally {
-                Utils.close(err);
-            }
+        try (InputStream errStream = connection.getErrorStream()) {
+            if (errStream != null) {
+                BufferedReader err = null;
+                try {
+                    String line;
+                    err = new BufferedReader(new InputStreamReader(errStream, Utils.UTF_8));
+                    while ((line = err.readLine()) != null) {
+                        sb.append(line).append("\n");
+                    }
+                } catch (Exception ex) {
+                    Main.error(e);
+                    Main.error(ex);
+                } finally {
+                    Utils.close(err);
+                }
+            }
+        } catch (IOException ex) {
+            Main.warn(ex);
         }
         final String msg = e.getMessage();
@@ -265,6 +268,4 @@
      */
     protected void downloadPluginIcons(String site, File destFile, ProgressMonitor monitor) {
-        InputStream in = null;
-        OutputStream out = null;
         try {
             site = site.replaceAll("%<(.*)>", "");
@@ -278,9 +279,12 @@
                 connection.setRequestProperty("Cache-Control", "no-cache");
             }
-            in = connection.getInputStream();
-            out = new FileOutputStream(destFile);
-            byte[] buffer = new byte[8192];
-            for (int read = in.read(buffer); read != -1; read = in.read(buffer)) {
-                out.write(buffer, 0, read);
+            try (
+                InputStream in = connection.getInputStream();
+                OutputStream out = new FileOutputStream(destFile)
+            ) {
+                byte[] buffer = new byte[8192];
+                for (int read = in.read(buffer); read != -1; read = in.read(buffer)) {
+                    out.write(buffer, 0, read);
+                }
             }
         } catch (MalformedURLException e) {
@@ -293,5 +297,4 @@
             return;
         } finally {
-            Utils.close(out);
             synchronized(this) {
                 if (connection != null) {
@@ -300,5 +303,4 @@
                 connection = null;
             }
-            Utils.close(in);
             monitor.finishTask();
         }
@@ -321,22 +323,16 @@
      */
     protected void cachePluginList(String site, String list) {
-        PrintWriter writer = null;
-        try {
-            File pluginDir = Main.pref.getPluginsDirectory();
-            if (!pluginDir.exists() && !pluginDir.mkdirs()) {
-                Main.warn(tr("Failed to create plugin directory ''{0}''. Cannot cache plugin list from plugin site ''{1}''.", pluginDir.toString(), site));
-            }
-            File cacheFile = createSiteCacheFile(pluginDir, site, CacheType.PLUGIN_LIST);
-            getProgressMonitor().subTask(tr("Writing plugin list to local cache ''{0}''", cacheFile.toString()));
-            writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(cacheFile), Utils.UTF_8));
+        File pluginDir = Main.pref.getPluginsDirectory();
+        if (!pluginDir.exists() && !pluginDir.mkdirs()) {
+            Main.warn(tr("Failed to create plugin directory ''{0}''. Cannot cache plugin list from plugin site ''{1}''.", pluginDir.toString(), site));
+        }
+        File cacheFile = createSiteCacheFile(pluginDir, site, CacheType.PLUGIN_LIST);
+        getProgressMonitor().subTask(tr("Writing plugin list to local cache ''{0}''", cacheFile.toString()));
+        try (PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(cacheFile), Utils.UTF_8))) {
             writer.write(list);
+            writer.flush();
         } catch(IOException e) {
             // just failed to write the cache file. No big deal, but log the exception anyway
             Main.error(e);
-        } finally {
-            if (writer != null) {
-                writer.flush();
-                Utils.close(writer);
-            }
         }
     }
