Index: trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java	(revision 7034)
+++ trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java	(revision 7037)
@@ -301,5 +301,4 @@
                             }
                         }
-                        Utils.close(reader);
                     } catch (Exception e) {
                         Main.error(e);
Index: trunk/src/org/openstreetmap/josm/data/AutosaveTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/AutosaveTask.java	(revision 7034)
+++ trunk/src/org/openstreetmap/josm/data/AutosaveTask.java	(revision 7037)
@@ -304,14 +304,8 @@
                 if (pidFile.exists()) {
                     try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(pidFile), Utils.UTF_8))) {
-                        try {
-                            String jvmId = reader.readLine();
-                            if (jvmId != null) {
-                                String pid = jvmId.split("@")[0];
-                                skipFile = jvmPerfDataFileExists(pid);
-                            }
-                        } catch (Throwable t) {
-                            Main.error(t);
-                        } finally {
-                            Utils.close(reader);
+                        String jvmId = reader.readLine();
+                        if (jvmId != null) {
+                            String pid = jvmId.split("@")[0];
+                            skipFile = jvmPerfDataFileExists(pid);
                         }
                     } catch (Throwable t) {
Index: trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java	(revision 7034)
+++ trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java	(revision 7037)
@@ -74,5 +74,4 @@
                 MirroredInputStream.cleanup(source);
             }
-            MirroredInputStream stream = null;
             try {
                 ImageryReader reader = new ImageryReader(source);
@@ -80,9 +79,7 @@
                 defaultLayers.addAll(result);
             } catch (IOException ex) {
-                Utils.close(stream);
                 Main.error(ex, false);
                 continue;
             } catch (SAXException ex) {
-                Utils.close(stream);
                 Main.error(ex);
                 continue;
Index: trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFile.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFile.java	(revision 7034)
+++ trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFile.java	(revision 7037)
@@ -155,6 +155,4 @@
         topLevelSubGrid = createSubGridTree(subGrid);
         lastSubGrid = topLevelSubGrid[0];
-
-        Utils.close(in);
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/help/HelpContentReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/help/HelpContentReader.java	(revision 7034)
+++ trunk/src/org/openstreetmap/josm/gui/help/HelpContentReader.java	(revision 7037)
@@ -45,11 +45,11 @@
             throw new MissingHelpContentException(helpTopicUrl);
         HttpURLConnection con = null;
-        BufferedReader in = null;
         try {
             URL u = new URL(helpTopicUrl);
             con = Utils.openHttpConnection(u);
             con.connect();
-            in = new BufferedReader(new InputStreamReader(con.getInputStream(), Utils.UTF_8));
-            return prepareHelpContent(in, dotest, u);
+            try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(), Utils.UTF_8))) {
+                return prepareHelpContent(in, dotest, u);
+            }
         } catch(MalformedURLException e) {
             throw new HelpContentReaderException(e);
@@ -64,6 +64,4 @@
             }
             throw ex;
-        } finally {
-            Utils.close(in);
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java	(revision 7034)
+++ trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java	(revision 7037)
@@ -7,4 +7,5 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.UnsupportedEncodingException;
@@ -197,7 +198,8 @@
 
     protected String extractToken(HttpURLConnection connection) {
-        BufferedReader r = null;
-        try {
-            r = new BufferedReader(new InputStreamReader(connection.getInputStream(), Utils.UTF_8));
+        try (
+            InputStream is = connection.getInputStream();
+            BufferedReader r = new BufferedReader(new InputStreamReader(is, Utils.UTF_8))
+        ) {
             String c;
             Pattern p = Pattern.compile(".*authenticity_token.*value=\"([^\"]+)\".*");
@@ -211,6 +213,4 @@
             Main.error(e);
             return null;
-        } finally {
-            Utils.close(r);
         }
         return null;
@@ -364,5 +364,4 @@
 
     protected void authenticateOsmSession(SessionId sessionId, String userName, String password) throws OsmLoginFailedException {
-        DataOutputStream dout = null;
         try {
             URL url = new URL(buildOsmLoginUrl());
@@ -392,8 +391,8 @@
             connection.connect();
 
-            dout = new DataOutputStream(connection.getOutputStream());
-            dout.writeBytes(request);
-            dout.flush();
-            Utils.close(dout);
+            try (DataOutputStream dout = new DataOutputStream(connection.getOutputStream())) {
+                dout.writeBytes(request);
+                dout.flush();
+            }
 
             // after a successful login the OSM website sends a redirect to a follow up page. Everything
@@ -409,5 +408,4 @@
             throw new OsmLoginFailedException(e);
         } finally {
-            Utils.close(dout);
             synchronized(this) {
                 connection = null;
@@ -456,5 +454,5 @@
             parameters.put("allow_read_prefs", "yes");
         }
-        if(privileges.isAllowModifyNotes()) {
+        if (privileges.isAllowModifyNotes()) {
             parameters.put("allow_write_notes", "yes");
         }
@@ -463,5 +461,4 @@
 
         String request = buildPostRequest(parameters);
-        DataOutputStream dout = null;
         try {
             URL url = new URL(oauthProviderParameters.getAuthoriseUrl());
@@ -480,15 +477,15 @@
             connection.connect();
 
-            dout = new DataOutputStream(connection.getOutputStream());
-            dout.writeBytes(request);
-            dout.flush();
+            try (DataOutputStream dout = new DataOutputStream(connection.getOutputStream())) {
+                dout.writeBytes(request);
+                dout.flush();
+            }
 
             int retCode = connection.getResponseCode();
             if (retCode != HttpURLConnection.HTTP_OK)
                 throw new OsmOAuthAuthorizationException(tr("Failed to authorize OAuth request  ''{0}''", requestToken.getKey()));
-        } catch(IOException e) {
-            throw new OsmOAuthAuthorizationException(e);
-        } finally {
-            Utils.close(dout);
+        } catch (IOException e) {
+            throw new OsmOAuthAuthorizationException(e);
+        } finally {
             synchronized(this) {
                 connection = null;
Index: trunk/src/org/openstreetmap/josm/gui/preferences/server/ApiUrlTestTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/server/ApiUrlTestTask.java	(revision 7034)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/server/ApiUrlTestTask.java	(revision 7037)
@@ -165,5 +165,4 @@
     @Override
     protected void realRun() throws SAXException, IOException, OsmTransferException {
-        BufferedReader bin = null;
         try {
             try {
@@ -195,8 +194,9 @@
             }
             StringBuilder changesets = new StringBuilder();
-            bin = new BufferedReader(new InputStreamReader(connection.getInputStream(), Utils.UTF_8));
-            String line;
-            while ((line = bin.readLine()) != null) {
-                changesets.append(line).append("\n");
+            try (BufferedReader bin = new BufferedReader(new InputStreamReader(connection.getInputStream(), Utils.UTF_8))) {
+                String line;
+                while ((line = bin.readLine()) != null) {
+                    changesets.append(line).append("\n");
+                }
             }
             if (! (changesets.toString().contains("<osm") && changesets.toString().contains("</osm>"))) {
@@ -215,6 +215,4 @@
             alertConnectionFailed();
             return;
-        } finally {
-            Utils.close(bin);
         }
     }
Index: trunk/src/org/openstreetmap/josm/io/GpxExporter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/GpxExporter.java	(revision 7034)
+++ trunk/src/org/openstreetmap/josm/io/GpxExporter.java	(revision 7037)
@@ -36,5 +36,4 @@
 import org.openstreetmap.josm.tools.CheckParameterUtil;
 import org.openstreetmap.josm.tools.GBC;
-import org.openstreetmap.josm.tools.Utils;
 
 public class GpxExporter extends FileExporter implements GpxConstants {
@@ -176,7 +175,6 @@
         }
 
-        OutputStream fo = null;
-        try {
-            fo = Compression.getCompressedFileOutputStream(file);
+        
+        try (OutputStream fo = Compression.getCompressedFileOutputStream(file)) {
             new GpxWriter(fo).write(gpxData);
             fo.flush();
@@ -185,6 +183,4 @@
             JOptionPane.showMessageDialog(Main.parent, tr("Error while exporting {0}:\n{1}", fn, x.getMessage()),
                     tr("Error"), JOptionPane.ERROR_MESSAGE);
-        } finally {
-            Utils.close(fo);
         }
     }
Index: trunk/src/org/openstreetmap/josm/io/NmeaReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/NmeaReader.java	(revision 7034)
+++ trunk/src/org/openstreetmap/josm/io/NmeaReader.java	(revision 7037)
@@ -174,8 +174,5 @@
         Collection<Collection<WayPoint>> currentTrack = new ArrayList<>();
 
-        BufferedReader rd = null;
-        try {
-            rd = new BufferedReader(new InputStreamReader(source, Utils.UTF_8));
-
+        try (BufferedReader rd = new BufferedReader(new InputStreamReader(source, Utils.UTF_8))) {
             StringBuilder sb = new StringBuilder(1024);
             int loopstart_char = rd.read();
@@ -209,8 +206,7 @@
         } catch (Exception e) {
             Main.warn(e);
-        } finally {
-            Utils.close(rd);
-        }
-    }
+        }
+    }
+
     private static class NMEAParserState {
         protected Collection<WayPoint> waypoints = new ArrayList<>();
Index: trunk/src/org/openstreetmap/josm/io/OsmApi.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/OsmApi.java	(revision 7034)
+++ trunk/src/org/openstreetmap/josm/io/OsmApi.java	(revision 7037)
@@ -629,19 +629,18 @@
                     activeConnection.setDoOutput(true);
                     activeConnection.setRequestProperty("Content-type", "text/xml");
-                    OutputStream out = activeConnection.getOutputStream();
-
-                    // It seems that certain bits of the Ruby API are very unhappy upon
-                    // receipt of a PUT/POST message without a Content-length header,
-                    // even if the request has no payload.
-                    // Since Java will not generate a Content-length header unless
-                    // we use the output stream, we create an output stream for PUT/POST
-                    // even if there is no payload.
-                    if (requestBody != null) {
-                        try (BufferedWriter bwr = new BufferedWriter(new OutputStreamWriter(out, Utils.UTF_8))) {
-                            bwr.write(requestBody);
-                            bwr.flush();
+                    try (OutputStream out = activeConnection.getOutputStream()) {
+                        // It seems that certain bits of the Ruby API are very unhappy upon
+                        // receipt of a PUT/POST message without a Content-length header,
+                        // even if the request has no payload.
+                        // Since Java will not generate a Content-length header unless
+                        // we use the output stream, we create an output stream for PUT/POST
+                        // even if there is no payload.
+                        if (requestBody != null) {
+                            try (BufferedWriter bwr = new BufferedWriter(new OutputStreamWriter(out, Utils.UTF_8))) {
+                                bwr.write(requestBody);
+                                bwr.flush();
+                            }
                         }
                     }
-                    Utils.close(out);
                 }
 
Index: trunk/src/org/openstreetmap/josm/io/OsmImporter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/OsmImporter.java	(revision 7034)
+++ trunk/src/org/openstreetmap/josm/io/OsmImporter.java	(revision 7037)
@@ -62,13 +62,9 @@
     @Override
     public void importData(File file, ProgressMonitor progressMonitor) throws IOException, IllegalDataException {
-        InputStream in = null;
-        try {
-            in = Compression.getUncompressedFileInputStream(file);
+        try (InputStream in = Compression.getUncompressedFileInputStream(file)) {
             importData(in, file, progressMonitor);
         } catch (FileNotFoundException e) {
             Main.error(e);
             throw new IOException(tr("File ''{0}'' does not exist.", file.getName()), e);
-        } finally {
-            Utils.close(in);
         }
     }
Index: trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControlHttpsServer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControlHttpsServer.java	(revision 7034)
+++ trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControlHttpsServer.java	(revision 7037)
@@ -29,5 +29,4 @@
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -60,9 +59,5 @@
                         Main.error(tr("Unable to find JOSM keystore at {0}. Remote control will not be available on HTTPS.", KEYSTORE_PATH));
                     } else {
-                        try {
-                            ks.load(in, password);
-                        } finally {
-                            Utils.close(in);
-                        }
+                        ks.load(in, password);
                         
                         if (Main.isDebugEnabled()) {
Index: trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java	(revision 7034)
+++ trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java	(revision 7037)
@@ -153,6 +153,4 @@
      */
     protected String downloadPluginList(String site, final ProgressMonitor monitor) {
-        BufferedReader in = null;
-
         /* replace %<x> with empty string or x=plugins (separated with comma) */
         String pl = Utils.join(",", Main.pref.getCollection("plugins"));
@@ -174,11 +172,12 @@
                 connection.setRequestProperty("Accept-Charset", "utf-8");
             }
-            in = new BufferedReader(new InputStreamReader(connection.getInputStream(), Utils.UTF_8));
-            StringBuilder sb = new StringBuilder();
-            String line;
-            while ((line = in.readLine()) != null) {
-                sb.append(line).append("\n");
-            }
-            return sb.toString();
+            try (BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), Utils.UTF_8))) {
+                StringBuilder sb = new StringBuilder();
+                String line;
+                while ((line = in.readLine()) != null) {
+                    sb.append(line).append("\n");
+                }
+                return sb.toString();
+            }
         } catch (MalformedURLException e) {
             if (canceled) return null;
@@ -197,5 +196,4 @@
                 connection = null;
             }
-            Utils.close(in);
             monitor.finishTask();
         }
@@ -206,8 +204,6 @@
         try (InputStream errStream = connection.getErrorStream()) {
             if (errStream != null) {
-                BufferedReader err = null;
-                try {
+                try (BufferedReader err = new BufferedReader(new InputStreamReader(errStream, Utils.UTF_8))) {
                     String line;
-                    err = new BufferedReader(new InputStreamReader(errStream, Utils.UTF_8));
                     while ((line = err.readLine()) != null) {
                         sb.append(line).append("\n");
@@ -216,6 +212,4 @@
                     Main.error(e);
                     Main.error(ex);
-                } finally {
-                    Utils.close(err);
                 }
             }
Index: trunk/src/org/openstreetmap/josm/tools/AudioUtil.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/AudioUtil.java	(revision 7034)
+++ trunk/src/org/openstreetmap/josm/tools/AudioUtil.java	(revision 7037)
@@ -38,5 +38,4 @@
                 * audioFormat.getFrameSize() /* bytes per frame */;
             double naturalLength = filesize / bytesPerSecond;
-            Utils.close(audioInputStream);
             double calibration = Main.pref.getDouble("audio.calibration", 1.0 /* default, ratio */);
             return naturalLength / calibration;
Index: trunk/src/org/openstreetmap/josm/tools/BugReportExceptionHandler.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/BugReportExceptionHandler.java	(revision 7034)
+++ trunk/src/org/openstreetmap/josm/tools/BugReportExceptionHandler.java	(revision 7037)
@@ -211,9 +211,9 @@
      */
     public static URL getBugReportUrl(String debugText) {
-        try {
+        try (
             ByteArrayOutputStream out = new ByteArrayOutputStream();
-            GZIPOutputStream gzip = new GZIPOutputStream(out);
+            GZIPOutputStream gzip = new GZIPOutputStream(out)
+        ) {
             gzip.write(debugText.getBytes(Utils.UTF_8));
-            Utils.close(gzip);
 
             return new URL(Main.getJOSMWebsite()+"/josmticket?" +
Index: trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java	(revision 7034)
+++ trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java	(revision 7037)
@@ -200,14 +200,14 @@
                 // Try lsb_release (only available on LSB-compliant Linux systems, see https://www.linuxbase.org/lsb-cert/productdir.php?by_prod )
                 Process p = Runtime.getRuntime().exec("lsb_release -ds");
-                BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream(), Utils.UTF_8));
-                String line = Utils.strip(input.readLine());
-                Utils.close(input);
-                if (line != null && !line.isEmpty()) {
-                    line = line.replaceAll("\"+","");
-                    line = line.replaceAll("NAME=",""); // strange code for some Gentoo's
-                    if(line.startsWith("Linux ")) // e.g. Linux Mint
-                        return line;
-                    else if(!line.isEmpty())
-                        return "Linux " + line;
+                try (BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream(), Utils.UTF_8))) {
+                    String line = Utils.strip(input.readLine());
+                    if (line != null && !line.isEmpty()) {
+                        line = line.replaceAll("\"+","");
+                        line = line.replaceAll("NAME=",""); // strange code for some Gentoo's
+                        if(line.startsWith("Linux ")) // e.g. Linux Mint
+                            return line;
+                        else if(!line.isEmpty())
+                            return "Linux " + line;
+                    }
                 }
             } catch (IOException e) {
Index: trunk/src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 7034)
+++ trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 7037)
@@ -801,17 +801,17 @@
         }
         Process p = new ProcessBuilder(command).start();
-        BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream(), UTF_8));
-        StringBuilder all = null;
-        String line;
-        while ((line = input.readLine()) != null) {
-            if (all == null) {
-                all = new StringBuilder(line);
-            } else {
-                all.append("\n");
-                all.append(line);
-            }
-        }
-        Utils.close(input);
-        return all != null ? all.toString() : null;
+        try (BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream(), UTF_8))) {
+            StringBuilder all = null;
+            String line;
+            while ((line = input.readLine()) != null) {
+                if (all == null) {
+                    all = new StringBuilder(line);
+                } else {
+                    all.append("\n");
+                    all.append(line);
+                }
+            }
+            return all != null ? all.toString() : null;
+        }
     }
 
