Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8258067

Clarify java.io.Reader.read(char[], ...) behavior for full array

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 17
    • core-libs
    • None
    • behavioral
    • minimal
    • This is a clarification of the specification which matches extant behavior so there is minimal risk.
    • Java API
    • SE

      Summary

      Add verbiage making explicit the behavior of the Reader methods read(char[] cbuf) when cbuf.length is zero and read(char[] cbuf, int off, int len) when len is zero.

      Problem

      The behaviors of read(char[] cbuf) when cbuf.length is zero and read(char[] cbuf, int off, int len) when len is zero are not as completely specified as in the analogous InputStream methods.

      Solution

      Add verbiage making explicit the behavior of the Reader methods read(char[] cbuf) when cbuf.length is zero and read(char[] cbuf, int off, int len) when len is zero.

      Specification

      To the specification of Reader::read(char[]) add the paragraph

      If the length of cbuf is zero, then no characters are read and 0 is returned; otherwise, there is an attempt to read at least one character. If no character is available because the stream is at its end, the value -1 is returned; otherwise, at least one character is read and stored into cbuf.

      and to that of Reader::read(char[],int,int) add the paragraph

      If len is zero, then no characters are read and 0 is returned; otherwise, there is an attempt to read at least one character. If no character is available because the stream is at its end, the value -1 is returned; otherwise, at least one character is read and stored into cbuf.

            bpb Brian Burkhalter
            webbuggrp Webbug Group
            Stuart Marks
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: