< prev index next >
src/java.base/share/classes/java/io/InputStream.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1994, 2017, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 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 >