JDK-8067661: transferTo proposal for Appendable

Patrick Reinhart patrick at reini.net
Wed Nov 1 14:57:30 UTC 2017


I tried to put that in my latest proposal:

/**
 * Reads all characters from this readable and writes the characters to
 * the given appendable in the order that they are read. On return, this
 * readable will be at end its data.
 * <p>
 * This method may block indefinitely reading from the readable, or
 * writing to the appendable. The behavior for the case where the readable
 * and/or appendable is <i>asynchronously closed</i>, or the thread
 * interrupted during the transfer, is highly readable and appendable
 * specific, and therefore not specified.
 * <p>
 * If an I/O error occurs reading from the readable or writing to the
 * appendable, then it may do so after some characters have been read or
 * written. Consequently the readable may not be at end of its data and
 * one, or both participants may be in an inconsistent state. That in mind
 * all additional measures required by one or both participants in order to
 * eventually free their internal resources have to be taken by the caller
 * of this method.
 *
 * @param  out the appendable, non-null
 * @return the number of characters transferred
 * @throws IOException if an I/O error occurs when reading or writing
 * @throws NullPointerException if {@code out} is {@code null}
 *
 * @since 18.3
 */
default long transferTo(Appendable out) throws IOException {
....
}

-Patrick

Am 01.11.2017 um 13:42 schrieb Alan Bateman:
> On 16/12/2014 22:54, Pavel Rappo wrote:
>> Hi Patrick, nice to hear from you again! I agree we should consider
>> adding this
>> method. Unfortunately, from the spec point of view I suppose this one
>> will
>> require a lot more chewing. For instance there's nothing that can be
>> closed
>> either in Readable or Appendable (in general case), since neither of
>> them is
>> java.io.Closeable or even java.lang.AutoCloseable. In my opinion, all
>> mentions
>> of 'close' operations should go.
> I agree that transferTo(Writer) is a no-brainer. When changed to be
> more general and Appendable then it might be simplest to just deal
> with the AutoCloseable case in the javadoc.
>
> -Alan





More information about the core-libs-dev mailing list