| java.lang.Object java.lang.AbstractStringBuilder java.lang.StringBuilder
StringBuilder | final public class StringBuilder extends AbstractStringBuilder implements java.io.Serializable,CharSequence(Code) | | A mutable sequence of characters. This class provides an API compatible
with StringBuffer , but with no guarantee of synchronization.
This class is designed for use as a drop-in replacement for
StringBuffer in places where the string buffer was being
used by a single thread (as is generally the case). Where possible,
it is recommended that this class be used in preference to
StringBuffer as it will be faster under most implementations.
The principal operations on a StringBuilder are the
append and insert methods, which are
overloaded so as to accept data of any type. Each effectively
converts a given datum to a string and then appends or inserts the
characters of that string to the string builder. The
append method always adds these characters at the end
of the builder; the insert method adds the characters at
a specified point.
For example, if z refers to a string builder object
whose current contents are "start ", then
the method call z.append("le") would cause the string
builder to contain "startle ", whereas
z.insert(4, "le") would alter the string builder to
contain "starlet ".
In general, if sb refers to an instance of a StringBuilder ,
then sb.append(x) has the same effect as
sb.insert(sb.length(), x) .
Every string builder has a capacity. As long as the length of the
character sequence contained in the string builder does not exceed
the capacity, it is not necessary to allocate a new internal
buffer. If the internal buffer overflows, it is automatically made larger.
Instances of StringBuilder are not safe for
use by multiple threads. If such synchronization is required then it is
recommended that
java.lang.StringBuffer be used.
author: Michael McCloskey version: 1.17, 05/05/07 See Also: java.lang.StringBuffer See Also: java.lang.String since: 1.5 |
Constructor Summary | |
public | StringBuilder() Constructs a string builder with no characters in it and an
initial capacity of 16 characters. | public | StringBuilder(int capacity) Constructs a string builder with no characters in it and an
initial capacity specified by the capacity argument. | public | StringBuilder(String str) Constructs a string builder initialized to the contents of the
specified string. | public | StringBuilder(CharSequence seq) Constructs a string builder that contains the same characters
as the specified CharSequence . |
Method Summary | |
public StringBuilder | append(Object obj) | public StringBuilder | append(String str) | public StringBuilder | append(StringBuffer sb) Appends the specified StringBuffer to this sequence.
The characters of the StringBuffer argument are appended,
in order, to this sequence, increasing the
length of this sequence by the length of the argument. | public StringBuilder | append(CharSequence s) | public StringBuilder | append(CharSequence s, int start, int end) | public StringBuilder | append(char str) | public StringBuilder | append(char str, int offset, int len) | public StringBuilder | append(boolean b) | public StringBuilder | append(char c) | public StringBuilder | append(int i) | public StringBuilder | append(long lng) | public StringBuilder | append(float f) | public StringBuilder | append(double d) | public StringBuilder | appendCodePoint(int codePoint) | public StringBuilder | delete(int start, int end) | public StringBuilder | deleteCharAt(int index) | public int | indexOf(String str) | public int | indexOf(String str, int fromIndex) | public StringBuilder | insert(int index, char str, int offset, int len) | public StringBuilder | insert(int offset, Object obj) | public StringBuilder | insert(int offset, String str) | public StringBuilder | insert(int offset, char str) | public StringBuilder | insert(int dstOffset, CharSequence s) | public StringBuilder | insert(int dstOffset, CharSequence s, int start, int end) | public StringBuilder | insert(int offset, boolean b) | public StringBuilder | insert(int offset, char c) | public StringBuilder | insert(int offset, int i) | public StringBuilder | insert(int offset, long l) | public StringBuilder | insert(int offset, float f) | public StringBuilder | insert(int offset, double d) | public int | lastIndexOf(String str) | public int | lastIndexOf(String str, int fromIndex) | public StringBuilder | replace(int start, int end, String str) | public StringBuilder | reverse() | public String | toString() |
serialVersionUID | final static long serialVersionUID(Code) | | use serialVersionUID for interoperability
|
StringBuilder | public StringBuilder()(Code) | | Constructs a string builder with no characters in it and an
initial capacity of 16 characters.
|
StringBuilder | public StringBuilder(int capacity)(Code) | | Constructs a string builder with no characters in it and an
initial capacity specified by the capacity argument.
Parameters: capacity - the initial capacity. throws: NegativeArraySizeException - if the capacity argument is less than 0 . |
StringBuilder | public StringBuilder(String str)(Code) | | Constructs a string builder initialized to the contents of the
specified string. The initial capacity of the string builder is
16 plus the length of the string argument.
Parameters: str - the initial contents of the buffer. throws: NullPointerException - if str is null |
StringBuilder | public StringBuilder(CharSequence seq)(Code) | | Constructs a string builder that contains the same characters
as the specified CharSequence . The initial capacity of
the string builder is 16 plus the length of the
CharSequence argument.
Parameters: seq - the sequence to copy. throws: NullPointerException - if seq is null |
append | public StringBuilder append(StringBuffer sb)(Code) | | Appends the specified StringBuffer to this sequence.
The characters of the StringBuffer argument are appended,
in order, to this sequence, increasing the
length of this sequence by the length of the argument.
If sb is null, then the four characters
"null" are appended to this sequence.
Let n be the length of this character sequence just prior to
execution of the append method. Then the character at index
k in the new character sequence is equal to the character at
index k in the old character sequence, if k is less than
n; otherwise, it is equal to the character at index k-n
in the argument sb .
Parameters: sb - the StringBuffer to append. a reference to this object. |
Methods inherited from java.lang.AbstractStringBuilder | public AbstractStringBuilder append(Object obj)(Code)(Java Doc) public AbstractStringBuilder append(String str)(Code)(Java Doc) public AbstractStringBuilder append(StringBuffer sb)(Code)(Java Doc) public AbstractStringBuilder append(CharSequence s)(Code)(Java Doc) public AbstractStringBuilder append(CharSequence s, int start, int end)(Code)(Java Doc) public AbstractStringBuilder append(char str)(Code)(Java Doc) public AbstractStringBuilder append(char str, int offset, int len)(Code)(Java Doc) public AbstractStringBuilder append(boolean b)(Code)(Java Doc) public AbstractStringBuilder append(char c)(Code)(Java Doc) public AbstractStringBuilder append(int i)(Code)(Java Doc) public AbstractStringBuilder append(long l)(Code)(Java Doc) public AbstractStringBuilder append(float f)(Code)(Java Doc) public AbstractStringBuilder append(double d)(Code)(Java Doc) public AbstractStringBuilder appendCodePoint(int codePoint)(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) public AbstractStringBuilder delete(int start, int end)(Code)(Java Doc) public AbstractStringBuilder deleteCharAt(int index)(Code)(Java Doc) public void ensureCapacity(int minimumCapacity)(Code)(Java Doc) void expandCapacity(int minimumCapacity)(Code)(Java Doc) public void getChars(int srcBegin, int srcEnd, char dst, int dstBegin)(Code)(Java Doc) final char[] getValue()(Code)(Java Doc) public int indexOf(String str)(Code)(Java Doc) public int indexOf(String str, int fromIndex)(Code)(Java Doc) public AbstractStringBuilder insert(int index, char str, int offset, int len)(Code)(Java Doc) public AbstractStringBuilder insert(int offset, Object obj)(Code)(Java Doc) public AbstractStringBuilder insert(int offset, String str)(Code)(Java Doc) public AbstractStringBuilder insert(int offset, char str)(Code)(Java Doc) public AbstractStringBuilder insert(int dstOffset, CharSequence s)(Code)(Java Doc) public AbstractStringBuilder insert(int dstOffset, CharSequence s, int start, int end)(Code)(Java Doc) public AbstractStringBuilder insert(int offset, boolean b)(Code)(Java Doc) public AbstractStringBuilder insert(int offset, char c)(Code)(Java Doc) public AbstractStringBuilder insert(int offset, int i)(Code)(Java Doc) public AbstractStringBuilder insert(int offset, long l)(Code)(Java Doc) public AbstractStringBuilder insert(int offset, float f)(Code)(Java Doc) public AbstractStringBuilder insert(int offset, double d)(Code)(Java Doc) public int lastIndexOf(String str)(Code)(Java Doc) public int lastIndexOf(String str, int fromIndex)(Code)(Java Doc) public int length()(Code)(Java Doc) public int offsetByCodePoints(int index, int codePointOffset)(Code)(Java Doc) public AbstractStringBuilder replace(int start, int end, String str)(Code)(Java Doc) public AbstractStringBuilder reverse()(Code)(Java Doc) public void setCharAt(int index, char ch)(Code)(Java Doc) public void setLength(int newLength)(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) abstract public String toString()(Code)(Java Doc) public void trimToSize()(Code)(Java Doc)
|
|
|