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

StringBuffer needs another append method

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.1.5, 1.3.0
    • core-libs
    • merlin
    • generic, x86
    • generic, windows_95
    • Verified



      Name: el35337 Date: 06/01/98


      It would be convenient to have a method in
      StringBuffer:

      StringBuffer append(StringBuffer strBuf)

      This would allow you to do an append of one
      StringBuffer to another without the overhead of
      creating a String object. It's annoying that you
      have to do this:

      bufa.append(bufb.toString());

      where bufa and bufb are both StringBuffers.

      I guess an equivalent insert method would also be
      useful.
      (Review ID: 32702)
      ======================================================================

      Name: krT82822 Date: 09/24/99


      orig synopsis: "Lack of an add method for StringBuffer class with StringBuffer as a parameter"

      StringBuffer doesn't have an "add" method with StringBuffer as
      a parameter. This method could help to "concatenate" one
      StringBuffer to another without converting to String or
      playing with "char" arrays.

      The following is the proposed implementation for this method:

          public synchronized StringBuffer append(StringBuffer strbuf)
          {
            int len = strbuf.length();
            int newcount = count + len;
            if (newcount > value.length)
              expandCapacity(newcount);
            System.arraycopy(strbuf.getValue(), 0, value, count, len);
            count = newcount;
            return this;
          }
      (Review ID: 95673)
      ======================================================================

            mmcclosksunw Michael Mccloskey (Inactive)
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: