< prev index next >

src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java

Print this page

        

@@ -43,10 +43,11 @@
 import java.util.NoSuchElementException;
 import java.util.Objects;
 import java.util.Set;
 import static java.nio.file.StandardOpenOption.*;
 import static java.nio.file.StandardCopyOption.*;
+import jdk.internal.io.IOSupport;
 
 /**
  * Base class for Path implementation of jrt file systems.
  *
  * @implNote This class needs to maintain JDK 8 source compatibility.

@@ -791,15 +792,11 @@
             // create directory or file
             target.createDirectory();
         } else {
             try (InputStream is = jrtfs.newInputStream(this);
                  OutputStream os = target.newOutputStream()) {
-                byte[] buf = new byte[8192];
-                int n;
-                while ((n = is.read(buf)) != -1) {
-                    os.write(buf, 0, n);
-                }
+                IOSupport.copy(is, os);
             }
         }
         if (copyAttrs) {
             BasicFileAttributeView view =
                 Files.getFileAttributeView(target, BasicFileAttributeView.class);
< prev index next >