Library enhancement proposal for copying data from/to Reader/Writer InputStream/OutputStream

Alan Bateman Alan.Bateman at oracle.com
Fri Dec 5 15:59:58 UTC 2014


On 05/12/2014 15:38, Chris Hegarty wrote:
> The addition of a copyTo method to java.io.InputStream is binary 
> compatible [1], but it may, in some cases, be source incompatible. I 
> believe the benefits of this approach out weigh the potential source 
> incompatibility, but it will be for the spec gods, the CCC, to have 
> final say.
>
> Here is what I propose. Let's take just InputStream.copyTo and bring 
> it, by itself, to a conclusion. And then revisit each of the 
> additional useful/convenience methods on their own merit.
I think the approach is good. An alternative name to consider is 
transferTo. For the javadoc then you can make it clear that the 
InputStream is at EOF when the method completes. I don't think the 
javadoc needs to say that the OutputStream should be closed promptly 
(think "cat a b c > d").

-Alan.



More information about the core-libs-dev mailing list