Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-564

The rules of ByteArrayOutputStream.write are not documented.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.6
    • 2.12.0
    • Streams/Writers
    • None

    Description

      When I call the ByteArrayOutputStream.write method, it returns exceptions. Its API document is not quite useful, since it does not define any rules. From the thrown exceptions, I cannot get any useful information either. Until I read the code, I understand its usage:

       public void write(final byte[] b, final int off, final int len) {
       if ((off < 0)
                      || (off > b.length)
                      || (len < 0)
                      || ((off + len) > b.length)
                      || ((off + len) < 0)) {
                  throw new IndexOutOfBoundsException();
              } else if (len == 0) {
                  return;
              }
      ...
      }
      

      Would you please explicitly introduce the rules in the doucment? Or, would you please add more messages to the thrown exception? Both ways can make the API easier to understand.

      Attachments

        Activity

          People

            Unassigned Unassigned
            haozhong Hao Zhong
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: