< prev index next >
src/java.base/share/classes/java/io/InputStream.java
Print this page
*** 27,36 ****
--- 27,37 ----
import java.util.ArrayList;
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
* an input stream of bytes.
*
*** 540,554 ****
*
* @since 9
*/
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;
}
}
--- 541,548 ----
*
* @since 9
*/
public long transferTo(OutputStream out) throws IOException {
Objects.requireNonNull(out, "out");
! return IOSupport.copy(this, out);
}
}
< prev index next >