public final class StringBuffer extends Object implements CharSequence
| Constructor and Description |
|---|
StringBuffer() |
StringBuffer(CharSequence seq) |
StringBuffer(int length) |
StringBuffer(String aString) |
| Modifier and Type | Method and Description |
|---|---|
StringBuffer |
append(boolean aBoolean) |
StringBuffer |
append(char aChar) |
StringBuffer |
append(char[] c) |
StringBuffer |
append(char[] c,
int off,
int len) |
StringBuffer |
append(CharSequence cs) |
StringBuffer |
append(CharSequence cs,
int start,
int end) |
StringBuffer |
append(double aDouble) |
StringBuffer |
append(float aFloat) |
StringBuffer |
append(int i) |
StringBuffer |
append(long aLong) |
StringBuffer |
append(Object aObject) |
StringBuffer |
append(String s) |
StringBuffer |
append(StringBuffer sb) |
StringBuffer |
appendCodePoint(int cp) |
int |
capacity() |
char |
charAt(int i)
Returns the character at the given index.
|
StringBuffer |
delete(int start,
int end) |
StringBuffer |
deleteCharAt(int index) |
void |
ensureCapacity(int minCapacity) |
void |
getChars(int start,
int end,
char[] dst,
int dstStart)
Retrieves the contents of the StringBuilder in the form of an array of characters.
|
int |
indexOf(String str) |
int |
indexOf(String str,
int fromIndex) |
StringBuffer |
insert(int offset,
char[] data)
Insert the
char[] argument into this
StringBuffer. |
StringBuffer |
insert(int offset,
char[] str,
int str_offset,
int len)
Insert a subarray of the
char[] argument into this
StringBuffer. |
StringBuffer |
insert(int offset,
Object obj)
Insert the
String value of the argument into this
StringBuffer. |
StringBuffer |
insert(int offset,
String str)
Insert the
String argument into this
StringBuffer. |
int |
lastIndexOf(String str) |
int |
lastIndexOf(String str,
int fromIndex) |
int |
length()
Returns the length of the sequence.
|
StringBuffer |
replace(int start,
int end,
String str)
Replace characters between index
start (inclusive) and
end (exclusive) with str. |
StringBuffer |
reverse()
Reverse the characters in this StringBuffer.
|
void |
setCharAt(int i,
char ch) |
void |
setLength(int newLen) |
CharSequence |
subSequence(int start,
int end)
Returns a new
CharSequence of the indicated range. |
String |
substring(int start) |
String |
substring(int start,
int end) |
String |
toString()
Returns the complete
CharSequence as a String. |
void |
trimToSize() |
public StringBuffer()
public StringBuffer(CharSequence seq)
public StringBuffer(int length)
public StringBuffer(String aString)
public StringBuffer append(boolean aBoolean)
public StringBuffer append(char aChar)
public StringBuffer append(char[] c)
public StringBuffer append(char[] c, int off, int len)
public StringBuffer append(CharSequence cs)
public StringBuffer append(CharSequence cs, int start, int end)
public StringBuffer append(double aDouble)
public StringBuffer append(float aFloat)
public StringBuffer append(int i)
public StringBuffer append(long aLong)
public StringBuffer append(Object aObject)
public StringBuffer append(String s)
public StringBuffer append(StringBuffer sb)
public StringBuffer appendCodePoint(int cp)
public int capacity()
public char charAt(int i)
CharSequencecharAt in interface CharSequencei - the index to retrieve frompublic StringBuffer delete(int start, int end)
public StringBuffer deleteCharAt(int index)
public void ensureCapacity(int minCapacity)
public void getChars(int start,
int end,
char[] dst,
int dstStart)
public int indexOf(String str)
public int indexOf(String str, int fromIndex)
public StringBuffer insert(int offset, char[] data)
char[] argument into this
StringBuffer.offset - the place to insert in this bufferdata - the char[] to insertStringBufferNullPointerException - if data is nullStringIndexOutOfBoundsException - if offset is out of boundsinsert(int, char[], int, int)public StringBuffer insert(int offset, char[] str, int str_offset, int len)
char[] argument into this
StringBuffer.offset - the place to insert in this bufferstr - the char[] to insertstr_offset - the index in str to start inserting fromlen - the number of characters to insertStringBufferNullPointerException - if str is nullStringIndexOutOfBoundsException - if any index is out of boundspublic StringBuffer insert(int offset, Object obj)
String value of the argument into this
StringBuffer. Uses String.valueOf() to convert
to String.offset - the place to insert in this bufferobj - the Object to convert and insertStringBufferStringIndexOutOfBoundsException - if offset is out of boundsString.valueOf(Object)public StringBuffer insert(int offset, String str)
String argument into this
StringBuffer. If str is null, the String "null" is used
instead.offset - the place to insert in this bufferstr - the String to insertStringBufferStringIndexOutOfBoundsException - if offset is out of boundspublic int lastIndexOf(String str)
public int lastIndexOf(String str, int fromIndex)
public int length()
CharSequencelength in interface CharSequencepublic StringBuffer replace(int start, int end, String str)
start (inclusive) and
end (exclusive) with str. If end
is larger than the size of this StringBuffer, all characters after
start are replaced.start - the beginning index of characters to delete (inclusive)end - the ending index of characters to delete (exclusive)str - the new String to insertStringBufferStringIndexOutOfBoundsException - if start or end are out of boundsNullPointerException - if str is nullpublic StringBuffer reverse()
StringBufferpublic void setCharAt(int i,
char ch)
public void setLength(int newLen)
public CharSequence subSequence(int start, int end)
CharSequenceCharSequence of the indicated range.subSequence in interface CharSequencestart - the start index (inclusive)end - the end index (exclusive)public String substring(int start)
public String substring(int start, int end)
public String toString()
CharSequenceCharSequence as a String.
Classes that implement this interface should return a String
which contains only the characters in the sequence in the correct order.toString in interface CharSequencetoString in class Objectpublic void trimToSize()