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)
======================================================================
- duplicates
-
JDK-4275366 Need StringBuffer.append(StringBuffer sb)
-
- Closed
-