| java.lang.Object java.lang.AbstractStringBuilder java.lang.StringBuffer
StringBuffer | final public class StringBuffer extends AbstractStringBuilder implements Appendable,Serializable,CharSequence(Code) | | StringBuffer is a variable size contiguous indexable array of characters. The
length of the StringBuffer is the number of characters it contains. The
capacity of the StringBuffer is the number of characters it can hold.
Characters may be inserted at any position up to the length of the
StringBuffer, increasing the length of the StringBuffer. Characters at any
position in the StringBuffer may be replaced, which does not affect the
StringBuffer length.
The capacity of a StringBuffer may be specified when the StringBuffer is
created. If the capacity of the StringBuffer is exceeded, the capacity is
increased.
See Also: String See Also: StringBuilder since: 1.0 |
Constructor Summary | |
public | StringBuffer() Constructs a new StringBuffer using the default capacity. | public | StringBuffer(int capacity) Constructs a new StringBuffer using the specified capacity. | public | StringBuffer(String string) Constructs a new StringBuffer containing the characters in the specified
string and the default capacity. | public | StringBuffer(CharSequence cs)
Constructs a StringBuffer and initializes it with the characters in the
CharSequence . |
Method Summary | |
public StringBuffer | append(boolean b) Adds the string representation of the specified boolean to the end of
this StringBuffer. | public synchronized StringBuffer | append(char ch) Adds the specified character to the end of this StringBuffer. | public StringBuffer | append(double d) Adds the string representation of the specified double to the end of this
StringBuffer. | public StringBuffer | append(float f) Adds the string representation of the specified float to the end of this
StringBuffer. | public StringBuffer | append(int value) Adds the string representation of the specified integer to the end of
this StringBuffer. | public StringBuffer | append(long l) Adds the string representation of the specified long to the end of this
StringBuffer. | public synchronized StringBuffer | append(Object obj) Adds the string representation of the specified object to the end of this
StringBuffer. | public synchronized StringBuffer | append(String string) Adds the specified string to the end of this StringBuffer. | public synchronized StringBuffer | append(StringBuffer sb) Adds the specified StringBuffer to the end of this StringBuffer. | public synchronized StringBuffer | append(char chars) Adds the character array to the end of this StringBuffer. | public synchronized StringBuffer | append(char chars, int start, int length) Adds the specified sequence of characters to the end of this
StringBuffer. | public synchronized StringBuffer | append(CharSequence s)
Appends the CharSequence to this buffer. | public synchronized StringBuffer | append(CharSequence s, int start, int end)
Appends the subsequence of the CharSequence to this
buffer. | public StringBuffer | appendCodePoint(int codePoint)
Appends the encoded Unicode code point to this object. | public synchronized char | charAt(int index) Answers the character at the specified offset in this StringBuffer. | public synchronized int | codePointAt(int index)
Retrieves the Unicode code point value at the index .
Parameters: index - The index to the char code unit within thisobject. | public synchronized int | codePointBefore(int index)
Retrieves the Unicode code point value that precedes the
index .
Parameters: index - The index to the char code unit within thisobject. | public synchronized int | codePointCount(int beginIndex, int endIndex)
Calculates the number of Unicode code points between
beginIndex and endIndex .
Parameters: beginIndex - The inclusive beginning index of the subsequence. Parameters: endIndex - The exclusive end index of the subsequence. | public synchronized StringBuffer | delete(int start, int end) Deletes a range of characters. | public synchronized StringBuffer | deleteCharAt(int location) | public synchronized void | ensureCapacity(int min) Ensures that this StringBuffer can hold the specified number of
characters without growing. | public synchronized void | getChars(int start, int end, char[] buffer, int index) Copies the specified characters in this StringBuffer to the character
array starting at the specified offset in the character array. | public synchronized int | indexOf(String subString, int start) Searches in this StringBuffer for the index of the specified character. | public synchronized StringBuffer | insert(int index, char ch) Inserts the character at the specified offset in this StringBuffer. | public StringBuffer | insert(int index, boolean b) Inserts the string representation of the specified boolean at the
specified offset in this StringBuffer. | public StringBuffer | insert(int index, int i) Inserts the string representation of the specified integer at the
specified offset in this StringBuffer. | public StringBuffer | insert(int index, long l) Inserts the string representation of the specified long at the specified
offset in this StringBuffer. | public StringBuffer | insert(int index, double d) Inserts the string representation of the specified double at the
specified offset in this StringBuffer. | public StringBuffer | insert(int index, float f) Inserts the string representation of the specified float at the specified
offset in this StringBuffer. | public StringBuffer | insert(int index, Object obj) Inserts the string representation of the specified object at the
specified offset in this StringBuffer. | public synchronized StringBuffer | insert(int index, String string) Inserts the string at the specified offset in this StringBuffer. | public synchronized StringBuffer | insert(int index, char[] chars) Inserts the character array at the specified offset in this StringBuffer. | public synchronized StringBuffer | insert(int index, char chars, int start, int length) Inserts the specified sequence of characters at the specified offset in
this StringBuffer. | public synchronized StringBuffer | insert(int index, CharSequence s)
Inserts the CharSequence into this buffer at the
index . | public synchronized StringBuffer | insert(int index, CharSequence s, int start, int end)
Inserts the CharSequence into this buffer at the
index . | public synchronized int | lastIndexOf(String subString, int start) Searches in this StringBuffer for the index of the specified character. | public synchronized int | offsetByCodePoints(int index, int codePointOffset)
Returns the index within this object that is offset from
index by codePointOffset code points.
Parameters: index - The index within this object to calculate the offset from. Parameters: codePointOffset - The number of code points to count. | public synchronized StringBuffer | replace(int start, int end, String string) Replace a range of characters with the characters in the specified
String. | public synchronized StringBuffer | reverse() Reverses the order of characters in this StringBuffer. | public synchronized void | setCharAt(int index, char ch) Sets the character at the specified offset in this StringBuffer. | public synchronized void | setLength(int length) Sets the length of this StringBuffer to the specified length. | public synchronized CharSequence | subSequence(int start, int end) Copies a range of characters into a new String. | public synchronized String | substring(int start) Copies a range of characters into a new String. | public synchronized String | substring(int start, int end) Copies a range of characters into a new String. | public synchronized String | toString() Answers the contents of this StringBuffer. | public synchronized void | trimToSize()
Trims the storage capacity of this buffer down to the size of the current
character sequence. |
StringBuffer | public StringBuffer()(Code) | | Constructs a new StringBuffer using the default capacity.
|
StringBuffer | public StringBuffer(int capacity)(Code) | | Constructs a new StringBuffer using the specified capacity.
Parameters: capacity - the initial capacity |
StringBuffer | public StringBuffer(String string)(Code) | | Constructs a new StringBuffer containing the characters in the specified
string and the default capacity.
Parameters: string - the string content with which to initialize the newStringBuffer instance throws: NullPointerException - on supplying a null value ofstring |
StringBuffer | public StringBuffer(CharSequence cs)(Code) | |
Constructs a StringBuffer and initializes it with the characters in the
CharSequence .
Parameters: cs - The CharSequence to initialize the instance. throws: NullPointerException - if the cs parameter is null . since: 1.5 |
append | public StringBuffer append(boolean b)(Code) | | Adds the string representation of the specified boolean to the end of
this StringBuffer.
Parameters: b - the boolean this StringBuffer |
append | public synchronized StringBuffer append(char ch)(Code) | | Adds the specified character to the end of this StringBuffer.
Parameters: ch - a character this StringBuffer |
append | public StringBuffer append(double d)(Code) | | Adds the string representation of the specified double to the end of this
StringBuffer.
Parameters: d - the double this StringBuffer |
append | public StringBuffer append(float f)(Code) | | Adds the string representation of the specified float to the end of this
StringBuffer.
Parameters: f - the float this StringBuffer |
append | public StringBuffer append(int value)(Code) | | Adds the string representation of the specified integer to the end of
this StringBuffer.
Parameters: value - the integer this StringBuffer |
append | public StringBuffer append(long l)(Code) | | Adds the string representation of the specified long to the end of this
StringBuffer.
Parameters: l - the long this StringBuffer |
append | public synchronized StringBuffer append(Object obj)(Code) | | Adds the string representation of the specified object to the end of this
StringBuffer.
Parameters: obj - the object this StringBuffer |
append | public synchronized StringBuffer append(String string)(Code) | | Adds the specified string to the end of this StringBuffer.
Parameters: string - the string this StringBuffer |
append | public synchronized StringBuffer append(StringBuffer sb)(Code) | | Adds the specified StringBuffer to the end of this StringBuffer.
Parameters: sb - the StringBuffer this StringBuffer since: 1.4 |
append | public synchronized StringBuffer append(char chars)(Code) | | Adds the character array to the end of this StringBuffer.
Parameters: chars - the character array this StringBuffer throws: NullPointerException - when chars is null |
append | public synchronized StringBuffer append(char chars, int start, int length)(Code) | | Adds the specified sequence of characters to the end of this
StringBuffer.
Parameters: chars - a character array Parameters: start - the starting offset Parameters: length - the number of characters this StringBuffer throws: ArrayIndexOutOfBoundsException - when length < 0, start < 0 orstart + length > chars.length throws: NullPointerException - when chars is null |
append | public synchronized StringBuffer append(CharSequence s)(Code) | |
Appends the CharSequence to this buffer. If the
CharSequence is null , then the string
"null" is appended.
Parameters: s - The CharSequence to append. A reference to this object. since: 1.5 |
append | public synchronized StringBuffer append(CharSequence s, int start, int end)(Code) | |
Appends the subsequence of the CharSequence to this
buffer. If the CharSequence is null , then
the string "null" is used to extract a subsequence.
Parameters: s - The CharSequence to append. Parameters: start - The inclusive start index of the subsequence of theCharSequence . Parameters: end - The exclusive end index of the subsequence of theCharSequence . A reference to this object. since: 1.5 throws: IndexOutOfBoundsException - if start or end are negative,start is greater than end orend is greater than the length ofs . |
appendCodePoint | public StringBuffer appendCodePoint(int codePoint)(Code) | |
Appends the encoded Unicode code point to this object. The code point is
converted to a char[] as defined by
Character.toChars(int) .
Parameters: codePoint - The Unicode code point to encode and append. A reference to this object. See Also: Character.toChars(int) since: 1.5 |
charAt | public synchronized char charAt(int index)(Code) | | Answers the character at the specified offset in this StringBuffer.
Parameters: index - the zero-based index in this StringBuffer the character at the index throws: IndexOutOfBoundsException - when index < 0 orindex >= length() |
codePointCount | public synchronized int codePointCount(int beginIndex, int endIndex)(Code) | |
Calculates the number of Unicode code points between
beginIndex and endIndex .
Parameters: beginIndex - The inclusive beginning index of the subsequence. Parameters: endIndex - The exclusive end index of the subsequence. The number of Unicode code points in the subsequence. throws: IndexOutOfBoundsException - if beginIndex is negative or greater thanendIndex or endIndex is greaterthan StringBuffer.length(). since: 1.5 |
delete | public synchronized StringBuffer delete(int start, int end)(Code) | | Deletes a range of characters.
Parameters: start - the offset of the first character Parameters: end - the offset one past the last character this StringBuffer throws: StringIndexOutOfBoundsException - when start < 0, start > end orend > length() |
deleteCharAt | public synchronized StringBuffer deleteCharAt(int location)(Code) | | Deletes a single character
Parameters: location - the offset of the character to delete this StringBuffer throws: StringIndexOutOfBoundsException - when location < 0 orlocation >= length() |
ensureCapacity | public synchronized void ensureCapacity(int min)(Code) | | Ensures that this StringBuffer can hold the specified number of
characters without growing.
Parameters: min - the minimum number of elements that this StringBuffer willhold before growing |
getChars | public synchronized void getChars(int start, int end, char[] buffer, int index)(Code) | | Copies the specified characters in this StringBuffer to the character
array starting at the specified offset in the character array.
Parameters: start - the starting offset of characters to copy Parameters: end - the ending offset of characters to copy Parameters: buffer - the destination character array Parameters: index - the starting offset in the character array throws: IndexOutOfBoundsException - when start < 0, end > length(),start > end, index < 0, end - start > buffer.length - index throws: NullPointerException - when buffer is null |
indexOf | public synchronized int indexOf(String subString, int start)(Code) | | Searches in this StringBuffer for the index of the specified character.
The search for the character starts at the specified offset and moves
towards the end.
Parameters: subString - the string to find Parameters: start - the starting offset the index in this StringBuffer of the specified character, -1 ifthe character isn't found See Also: StringBuffer.lastIndexOf(String,int) since: 1.4 |
insert | public synchronized StringBuffer insert(int index, char ch)(Code) | | Inserts the character at the specified offset in this StringBuffer.
Parameters: index - the index at which to insert Parameters: ch - the character to insert this StringBuffer throws: ArrayIndexOutOfBoundsException - when index < 0 orindex > length() |
insert | public StringBuffer insert(int index, boolean b)(Code) | | Inserts the string representation of the specified boolean at the
specified offset in this StringBuffer.
Parameters: index - the index at which to insert Parameters: b - the boolean to insert this StringBuffer throws: StringIndexOutOfBoundsException - when index < 0 orindex > length() |
insert | public StringBuffer insert(int index, int i)(Code) | | Inserts the string representation of the specified integer at the
specified offset in this StringBuffer.
Parameters: index - the index at which to insert Parameters: i - the integer to insert this StringBuffer throws: StringIndexOutOfBoundsException - when index < 0 orindex > length() |
insert | public StringBuffer insert(int index, long l)(Code) | | Inserts the string representation of the specified long at the specified
offset in this StringBuffer.
Parameters: index - the index at which to insert Parameters: l - the long to insert this StringBuffer throws: StringIndexOutOfBoundsException - when index < 0 orindex > length() |
insert | public StringBuffer insert(int index, double d)(Code) | | Inserts the string representation of the specified double at the
specified offset in this StringBuffer.
Parameters: index - the index at which to insert Parameters: d - the double to insert this StringBuffer throws: StringIndexOutOfBoundsException - when index < 0 orindex > length() |
insert | public StringBuffer insert(int index, float f)(Code) | | Inserts the string representation of the specified float at the specified
offset in this StringBuffer.
Parameters: index - the index at which to insert Parameters: f - the float to insert this StringBuffer throws: StringIndexOutOfBoundsException - when index < 0 orindex > length() |
insert | public StringBuffer insert(int index, Object obj)(Code) | | Inserts the string representation of the specified object at the
specified offset in this StringBuffer.
Parameters: index - the index at which to insert Parameters: obj - the object to insert this StringBuffer throws: StringIndexOutOfBoundsException - when index < 0 orindex > length() |
insert | public synchronized StringBuffer insert(int index, String string)(Code) | | Inserts the string at the specified offset in this StringBuffer.
Parameters: index - the index at which to insert Parameters: string - the string to insert this StringBuffer throws: StringIndexOutOfBoundsException - when index < 0 orindex > length() |
insert | public synchronized StringBuffer insert(int index, char[] chars)(Code) | | Inserts the character array at the specified offset in this StringBuffer.
Parameters: index - the index at which to insert Parameters: chars - the character array to insert this StringBuffer throws: StringIndexOutOfBoundsException - when index < 0 orindex > length() throws: NullPointerException - when chars is null |
insert | public synchronized StringBuffer insert(int index, char chars, int start, int length)(Code) | | Inserts the specified sequence of characters at the specified offset in
this StringBuffer.
Parameters: index - the index at which to insert Parameters: chars - a character array Parameters: start - the starting offset Parameters: length - the number of characters this StringBuffer throws: StringIndexOutOfBoundsException - when length < 0, start < 0, start + length > chars.length, index < 0 or index > length() throws: NullPointerException - when chars is null |
insert | public synchronized StringBuffer insert(int index, CharSequence s)(Code) | |
Inserts the CharSequence into this buffer at the
index . If CharSequence is
null , then the string "null" is inserted.
Parameters: index - The index of this buffer to insert the sequence. Parameters: s - The CharSequence to insert. A reference to this object. since: 1.5 throws: IndexOutOfBoundsException - if the index is invalid. |
insert | public synchronized StringBuffer insert(int index, CharSequence s, int start, int end)(Code) | |
Inserts the CharSequence into this buffer at the
index . If CharSequence is
null , then the string "null" is inserted.
Parameters: index - The index of this buffer to insert the sequence. Parameters: s - The CharSequence to insert. Parameters: start - The inclusive start index of the subsequence of theCharSequence . Parameters: end - The exclusive end index of the subsequence of theCharSequence . A reference to this object. since: 1.5 throws: IndexOutOfBoundsException - if index is negative or greater than thecurrent length, start or end are negative, start is greater thanend or end is greater than thelength of s . |
lastIndexOf | public synchronized int lastIndexOf(String subString, int start)(Code) | | Searches in this StringBuffer for the index of the specified character.
The search for the character starts at the specified offset and moves
towards the beginning.
Parameters: subString - the string to find Parameters: start - the starting offset the index in this StringBuffer of the specified character, -1 ifthe character isn't found See Also: StringBuffer.indexOf(String,int) since: 1.4 |
offsetByCodePoints | public synchronized int offsetByCodePoints(int index, int codePointOffset)(Code) | |
Returns the index within this object that is offset from
index by codePointOffset code points.
Parameters: index - The index within this object to calculate the offset from. Parameters: codePointOffset - The number of code points to count. The index within this object that is the offset. throws: IndexOutOfBoundsException - if index is negative or greater thanStringBuffer.length() or if there aren't enough code pointsbefore or after index to matchcodePointOffset . since: 1.5 |
replace | public synchronized StringBuffer replace(int start, int end, String string)(Code) | | Replace a range of characters with the characters in the specified
String.
Parameters: start - the offset of the first character Parameters: end - the offset one past the last character Parameters: string - a String this StringBuffer throws: StringIndexOutOfBoundsException - when start < 0 or start > end |
reverse | public synchronized StringBuffer reverse()(Code) | | Reverses the order of characters in this StringBuffer.
this StringBuffer |
setCharAt | public synchronized void setCharAt(int index, char ch)(Code) | | Sets the character at the specified offset in this StringBuffer.
Parameters: index - the zero-based index in this StringBuffer Parameters: ch - the character throws: IndexOutOfBoundsException - when index < 0 orindex >= length() |
setLength | public synchronized void setLength(int length)(Code) | | Sets the length of this StringBuffer to the specified length. If there
are more than length characters in this StringBuffer, the characters at
end are lost. If there are less than length characters in the
StringBuffer, the additional characters are set to \u0000 .
Parameters: length - the new length of this StringBuffer throws: IndexOutOfBoundsException - when length < 0 See Also: StringBuffer.length() |
subSequence | public synchronized CharSequence subSequence(int start, int end)(Code) | | Copies a range of characters into a new String.
Parameters: start - the offset of the first character Parameters: end - the offset one past the last character a new String containing the characters from start to end - 1 throws: IndexOutOfBoundsException - when start < 0, start > end orend > length() since: 1.4 |
substring | public synchronized String substring(int start)(Code) | | Copies a range of characters into a new String.
Parameters: start - the offset of the first character a new String containing the characters from start to the end ofthe string throws: StringIndexOutOfBoundsException - when start < 0 orstart > length() |
substring | public synchronized String substring(int start, int end)(Code) | | Copies a range of characters into a new String.
Parameters: start - the offset of the first character Parameters: end - the offset one past the last character a new String containing the characters from start to end - 1 throws: StringIndexOutOfBoundsException - when start < 0, start > end orend > length() |
toString | public synchronized String toString()(Code) | | Answers the contents of this StringBuffer.
a String containing the characters in this StringBuffer |
trimToSize | public synchronized void trimToSize()(Code) | |
Trims the storage capacity of this buffer down to the size of the current
character sequence. Execution of this method may change the results
returned by the
StringBuffer.capacity() method, but this is not required.
since: 1.5 |
Fields inherited from java.lang.AbstractStringBuilder | final static int INITIAL_CAPACITY(Code)(Java Doc)
|
Methods inherited from java.lang.AbstractStringBuilder | final void append0(char chars)(Code)(Java Doc) final void append0(char chars, int start, int length)(Code)(Java Doc) final void append0(char ch)(Code)(Java Doc) final void append0(String string)(Code)(Java Doc) final void append0(CharSequence s, int start, int end)(Code)(Java Doc) final void appendNull()(Code)(Java Doc) public int capacity()(Code)(Java Doc) public char charAt(int index)(Code)(Java Doc) public int codePointAt(int index)(Code)(Java Doc) public int codePointBefore(int index)(Code)(Java Doc) public int codePointCount(int beginIndex, int endIndex)(Code)(Java Doc) final void delete0(int start, int end)(Code)(Java Doc) final void deleteCharAt0(int location)(Code)(Java Doc) public void ensureCapacity(int min)(Code)(Java Doc) public void getChars(int start, int end, char[] dest, int destStart)(Code)(Java Doc) final char[] getValue()(Code)(Java Doc) public int indexOf(String string)(Code)(Java Doc) public int indexOf(String subString, int start)(Code)(Java Doc) final void insert0(int index, char[] chars)(Code)(Java Doc) final void insert0(int index, char[] chars, int start, int length)(Code)(Java Doc) final void insert0(int index, char ch)(Code)(Java Doc) final void insert0(int index, String string)(Code)(Java Doc) final void insert0(int index, CharSequence s, int start, int end)(Code)(Java Doc) public int lastIndexOf(String string)(Code)(Java Doc) public int lastIndexOf(String subString, int start)(Code)(Java Doc) public int length()(Code)(Java Doc) public int offsetByCodePoints(int index, int codePointOffset)(Code)(Java Doc) final void replace0(int start, int end, String string)(Code)(Java Doc) final void reverse0()(Code)(Java Doc) final void set(char[] val, int len) throws InvalidObjectException(Code)(Java Doc) public void setCharAt(int index, char ch)(Code)(Java Doc) public void setLength(int length)(Code)(Java Doc) final char[] shareValue()(Code)(Java Doc) public CharSequence subSequence(int start, int end)(Code)(Java Doc) public String substring(int start)(Code)(Java Doc) public String substring(int start, int end)(Code)(Java Doc) public String toString()(Code)(Java Doc) public void trimToSize()(Code)(Java Doc)
|
|
|