--- old/src/java.base/share/classes/java/io/InputStream.java 2017-12-22 15:05:49.000000000 -0800 +++ new/src/java.base/share/classes/java/io/InputStream.java 2017-12-22 15:05:48.000000000 -0800 @@ -29,6 +29,7 @@ import java.util.Arrays; import java.util.List; import java.util.Objects; +import jdk.internal.io.IOSupport; /** * This abstract class is the superclass of all classes representing @@ -542,13 +543,6 @@ */ public long transferTo(OutputStream out) throws IOException { Objects.requireNonNull(out, "out"); - long transferred = 0; - byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; - int read; - while ((read = this.read(buffer, 0, DEFAULT_BUFFER_SIZE)) >= 0) { - out.write(buffer, 0, read); - transferred += read; - } - return transferred; + return IOSupport.copy(this, out); } }