--- old/src/java.base/share/classes/java/io/InputStream.java 2018-01-04 08:51:06.000000000 -0800 +++ new/src/java.base/share/classes/java/io/InputStream.java 2018-01-04 08:51:06.000000000 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -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); } }