Index: trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java	(revision 9278)
+++ trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java	(revision 9280)
@@ -7,8 +7,9 @@
 import java.awt.event.ActionEvent;
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
 import java.util.Arrays;
 import java.util.List;
@@ -153,7 +154,5 @@
                         file = File.createTempFile("session_", ".joz", Utils.getJosmTempDir());
                         tempFile = true;
-                        try (FileOutputStream out = new FileOutputStream(file)) {
-                            Utils.copyStream(is, out);
-                        }
+                        Files.copy(is, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
                     }
                     reader.loadSession(file, zip, monitor);
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java	(revision 9278)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java	(revision 9280)
@@ -16,13 +16,12 @@
 import java.awt.event.MouseEvent;
 import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
 import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.io.OutputStream;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -510,17 +509,11 @@
                 try {
                     InputStream in = s.getSourceInputStream();
-                    try (
-                        InputStream bis = new BufferedInputStream(in);
-                        OutputStream bos = new BufferedOutputStream(new FileOutputStream(file))
-                    ) {
-                        byte[] buffer = new byte[4096];
-                        int length;
-                        while ((length = bis.read(buffer)) > -1 && !canceled) {
-                            bos.write(buffer, 0, length);
-                        }
+                    try (InputStream bis = new BufferedInputStream(in)) {
+                        Files.copy(bis, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
                     } finally {
                         s.closeSourceInputStream(in);
                     }
                 } catch (IOException e) {
+                    Main.warn(e);
                     error = true;
                 }
Index: trunk/src/org/openstreetmap/josm/gui/io/DownloadFileTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/DownloadFileTask.java	(revision 9278)
+++ trunk/src/org/openstreetmap/josm/gui/io/DownloadFileTask.java	(revision 9280)
@@ -5,5 +5,4 @@
 
 import java.awt.Component;
-import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
@@ -14,4 +13,6 @@
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
 import java.util.Enumeration;
 import java.util.zip.ZipEntry;
@@ -182,13 +183,6 @@
                 if (ze.isDirectory()) {
                     newFile.mkdirs();
-                } else try (
-                    InputStream is = zf.getInputStream(ze);
-                    OutputStream os = new BufferedOutputStream(new FileOutputStream(newFile))
-                ) {
-                    byte[] buffer = new byte[8192];
-                    int read;
-                    while ((read = is.read(buffer)) != -1) {
-                        os.write(buffer, 0, read);
-                    }
+                } else try (InputStream is = zf.getInputStream(ze)) {
+                    Files.copy(is, newFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
                 }
             }
Index: trunk/src/org/openstreetmap/josm/io/CachedFile.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/CachedFile.java	(revision 9278)
+++ trunk/src/org/openstreetmap/josm/io/CachedFile.java	(revision 9280)
@@ -5,15 +5,14 @@
 
 import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -429,14 +428,6 @@
                 return localFile;
             }
-            try (
-                InputStream bis = new BufferedInputStream(con.getContent());
-                OutputStream fos = new FileOutputStream(destDirFile);
-                OutputStream bos = new BufferedOutputStream(fos)
-            ) {
-                byte[] buffer = new byte[4096];
-                int length;
-                while ((length = bis.read(buffer)) > -1) {
-                    bos.write(buffer, 0, length);
-                }
+            try (InputStream bis = new BufferedInputStream(con.getContent())) {
+                Files.copy(bis, destDirFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
             }
             localFile = new File(destDir, localPath);
Index: trunk/src/org/openstreetmap/josm/plugins/Plugin.java
===================================================================
--- trunk/src/org/openstreetmap/josm/plugins/Plugin.java	(revision 9278)
+++ trunk/src/org/openstreetmap/josm/plugins/Plugin.java	(revision 9280)
@@ -4,9 +4,10 @@
 import java.io.File;
 import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
@@ -119,15 +120,9 @@
             pluginDir.mkdirs();
         }
-        try (
-            FileOutputStream out = new FileOutputStream(new File(pluginDirName, to));
-            InputStream in = getClass().getResourceAsStream(from)
-        ) {
+        try (InputStream in = getClass().getResourceAsStream(from)) {
             if (in == null) {
                 throw new IOException("Resource not found: "+from);
             }
-            byte[] buffer = new byte[8192];
-            for (int len = in.read(buffer); len > 0; len = in.read(buffer)) {
-                out.write(buffer, 0, len);
-            }
+            Files.copy(in, new File(pluginDirName, to).toPath(), StandardCopyOption.REPLACE_EXISTING);
         }
     }
Index: trunk/src/org/openstreetmap/josm/plugins/PluginDownloadTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/plugins/PluginDownloadTask.java	(revision 9278)
+++ trunk/src/org/openstreetmap/josm/plugins/PluginDownloadTask.java	(revision 9280)
@@ -6,10 +6,10 @@
 import java.awt.Component;
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
 import java.util.Collection;
 import java.util.LinkedList;
@@ -127,12 +127,6 @@
                         .connect();
             }
-            try (
-                InputStream in = downloadConnection.getContent();
-                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);
-                }
+            try (InputStream in = downloadConnection.getContent()) {
+                Files.copy(in, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
             }
         } catch (MalformedURLException e) {
Index: trunk/src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 9278)
+++ trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 9280)
@@ -23,5 +23,4 @@
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.HttpURLConnection;
@@ -435,22 +434,4 @@
 
     /**
-     * Copy data from source stream to output stream.
-     * @param source source stream
-     * @param destination target stream
-     * @return number of bytes copied
-     * @throws IOException if any I/O error occurs
-     */
-    public static int copyStream(InputStream source, OutputStream destination) throws IOException {
-        int count = 0;
-        byte[] b = new byte[512];
-        int read;
-        while ((read = source.read(b)) != -1) {
-            count += read;
-            destination.write(b, 0, read);
-        }
-        return count;
-    }
-
-    /**
      * Deletes a directory recursively.
      * @param path The directory to delete
