| java.lang.Object | |
| ↳ | java.lang.StringBuilder | 
A modifiable sequence of characters for use in creating strings. This class is intended as a direct replacement of StringBuffer for non-concurrent use; unlike StringBuffer this class is not synchronized. 
For particularly complex string-building needs, consider Formatter. 
The majority of the modification methods on this class return this so that method calls can be chained together. For example: new StringBuilder("a").append("b").append("c").toString().
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|  | 
           Constructs an instance with an initial capacity of 
            16. | ||||||||||
|  | 
           Constructs an instance with the specified capacity.
           | ||||||||||
|  | 
           Constructs an instance that's initialized with the contents of the specified 
            CharSequence. | ||||||||||
|  | 
           Constructs an instance that's initialized with the contents of the specified 
            String. | ||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|  | 
           Appends the string representation of the specified subset of the 
            char[]. | ||||||||||
|  | 
           Appends the string representation of the specified 
            doublevalue. | ||||||||||
|  | 
           Appends the string representation of the specified 
            longvalue. | ||||||||||
|  | 
           Appends the string representation of the specified 
            booleanvalue. | ||||||||||
|  | 
           Appends the string representation of the specified 
            floatvalue. | ||||||||||
|  | 
           Appends the string representation of the specified 
            char[]. | ||||||||||
|  | 
           Appends the string representation of the specified 
            intvalue. | ||||||||||
|  | 
           Appends the contents of the specified 
            StringBuffer. | ||||||||||
|  | 
           Appends the string representation of the specified 
            CharSequence. | ||||||||||
|  | 
           Appends the string representation of the specified 
            charvalue. | ||||||||||
|  | 
           Appends the contents of the specified string.
           | ||||||||||
|  | 
           Appends the string representation of the specified subsequence of the 
            CharSequence. | ||||||||||
|  | 
           Appends the string representation of the specified 
            Object. | ||||||||||
|  | 
           Appends the encoded Unicode code point.
           | ||||||||||
|  | 
           Returns the number of characters that can be held without growing.
           | ||||||||||
|  | 
           Retrieves the character at the 
            index. | ||||||||||
|  | 
           Retrieves the Unicode code point value at the 
            index. | ||||||||||
|  | 
           Retrieves the Unicode code point value that precedes the 
            index. | ||||||||||
|  | 
           Calculates the number of Unicode code points between 
            startandend. | ||||||||||
|  | 
           Deletes a sequence of characters specified by 
            startandend. | ||||||||||
|  | 
           Deletes the character at the specified index.
           | ||||||||||
|  | 
           Ensures that this object has a minimum capacity available before requiring the internal buffer to be enlarged.
           | ||||||||||
|  | 
           Copies the requested sequence of characters into 
            dstpassed starting atdst. | ||||||||||
|  | 
           Searches for the index of the specified character.
           | ||||||||||
|  | 
           Searches for the first index of the specified character.
           | ||||||||||
|  | 
           Inserts the string representation of the specified subsequence of the 
            CharSequenceat the specifiedoffset. | ||||||||||
|  | 
           Inserts the string representation of the specified 
            intvalue at the specifiedoffset. | ||||||||||
|  | 
           Inserts the string representation of the specified 
            doublevalue at the specifiedoffset. | ||||||||||
|  | 
           Inserts the string representation of the specified subsequence of the 
            char[]at the specifiedoffset. | ||||||||||
|  | 
           Inserts the specified string at the specified 
            offset. | ||||||||||
|  | 
           Inserts the string representation of the specified 
            longvalue at the specifiedoffset. | ||||||||||
|  | 
           Inserts the string representation of the specified 
            Objectat the specifiedoffset. | ||||||||||
|  | 
           Inserts the string representation of the specified 
            floatvalue at the specifiedoffset. | ||||||||||
|  | 
           Inserts the string representation of the specified 
            charvalue at the specifiedoffset. | ||||||||||
|  | 
           Inserts the string representation of the specified 
            char[]at the specifiedoffset. | ||||||||||
|  | 
           Inserts the string representation of the specified 
            CharSequenceat the specifiedoffset. | ||||||||||
|  | 
           Inserts the string representation of the specified 
            booleanvalue at the specifiedoffset. | ||||||||||
|  | 
           Searches for the last index of the specified character.
           | ||||||||||
|  | 
           Searches for the index of the specified character.
           | ||||||||||
|  | 
           The current length.
           | ||||||||||
|  | 
           Returns the index that is offset 
            codePointOffsetcode points fromindex. | ||||||||||
|  | 
           Replaces the specified subsequence in this builder with the specified string.
           | ||||||||||
|  | 
           Reverses the order of characters in this builder.
           | ||||||||||
|  | 
           Sets the character at the 
            index. | ||||||||||
|  | 
           Sets the current length to a new value.
           | ||||||||||
|  | 
           Returns a 
            CharSequenceof the subsequence from thestartindex to theendindex. | ||||||||||
|  | 
           Returns the String value of the subsequence from the 
            startindex to the current end. | ||||||||||
|  | 
           Returns the String value of the subsequence from the 
            startindex to theendindex. | ||||||||||
|  | 
           Returns the contents of this builder.
           | ||||||||||
|  | 
           Trims off any extra capacity beyond the current length.
           | ||||||||||
| [Expand] 
           Inherited Methods
           | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|  From class java.lang.Object | |||||||||||
|  From interface java.lang.Appendable | |||||||||||
|  From interface java.lang.CharSequence | |||||||||||
Constructs an instance with an initial capacity of 16.
Constructs an instance with the specified capacity.
| capacity | the initial capacity to use. | 
|---|
| NegativeArraySizeException | if the specified capacityis negative. | 
|---|
Constructs an instance that's initialized with the contents of the specified CharSequence. The capacity of the new builder will be the length of the CharSequence plus 16.
| seq | the CharSequenceto copy into the builder. | 
|---|
| NullPointerException | if seqisnull. | 
|---|
Constructs an instance that's initialized with the contents of the specified String. The capacity of the new builder will be the length of the String plus 16.
| str | the Stringto copy into the builder. | 
|---|
| NullPointerException | if strisnull. | 
|---|
Appends the string representation of the specified subset of the char[]. The char[] value is converted to a String according to the rule defined by valueOf(char[], int, int).
| str | the char[]to append. | 
|---|---|
| offset | the inclusive offset index. | 
| len | the number of characters. | 
| ArrayIndexOutOfBoundsException | if offsetandlendo not specify a valid subsequence. | 
|---|
Appends the string representation of the specified double value. The double value is converted to a string according to the rule defined by valueOf(double).
| d | the doublevalue to append. | 
|---|
Appends the string representation of the specified long value. The long value is converted to a string according to the rule defined by valueOf(long).
| l | the longvalue. | 
|---|
Appends the string representation of the specified boolean value. The boolean value is converted to a String according to the rule defined by valueOf(boolean).
| b | the booleanvalue to append. | 
|---|
Appends the string representation of the specified float value. The float value is converted to a string according to the rule defined by valueOf(float).
| f | the floatvalue to append. | 
|---|
Appends the string representation of the specified char[]. The char[] is converted to a string according to the rule defined by valueOf(char[]).
| chars | the char[]to append.. | 
|---|
Appends the string representation of the specified int value. The int value is converted to a string according to the rule defined by valueOf(int).
| i | the intvalue to append. | 
|---|
Appends the contents of the specified StringBuffer. If the StringBuffer is null, then the string "null" is appended.
| sb | the StringBufferto append. | 
|---|
Appends the string representation of the specified CharSequence. If the CharSequence is null, then the string "null" is appended.
| csq | the CharSequenceto append. | 
|---|
Appends the string representation of the specified char value. The char value is converted to a string according to the rule defined by valueOf(char).
| c | the charvalue to append. | 
|---|
Appends the contents of the specified string. If the string is null, then the string "null" is appended.
| str | the string to append. | 
|---|
Appends the string representation of the specified subsequence of the CharSequence. If the CharSequence is null, then the string "null" is used to extract the subsequence from.
| csq | the CharSequenceto append. | 
|---|---|
| start | the beginning index. | 
| end | the ending index. | 
| IndexOutOfBoundsException | if startorendare negative,startis greater thanendorendis greater than the length ofcsq. | 
|---|
Appends the string representation of the specified Object. The Object value is converted to a string according to the rule defined by valueOf(Object).
| obj | the Objectto append. | 
|---|
Appends the encoded Unicode code point. The code point is converted to a char[] as defined by toChars(int).
| codePoint | the Unicode code point to encode and append. | 
|---|
Returns the number of characters that can be held without growing.
Retrieves the character at the index.
| index | the index of the character to retrieve. | 
|---|
| IndexOutOfBoundsException | if indexis negative or greater than or equal to the currentlength(). | 
|---|
Retrieves the Unicode code point value at the index.
| index | the index to the charcode unit. | 
|---|
| IndexOutOfBoundsException | if indexis negative or greater than or equal tolength(). | 
|---|
Retrieves the Unicode code point value that precedes the index.
| index | the index to the charcode unit within this object. | 
|---|
| IndexOutOfBoundsException | if indexis less than 1 or greater thanlength(). | 
|---|
Calculates the number of Unicode code points between start and end.
| start | the inclusive beginning index of the subsequence. | 
|---|---|
| end | the exclusive end index of the subsequence. | 
| IndexOutOfBoundsException | if startis negative or greater thanendorendis greater thanlength(). | 
|---|
Deletes a sequence of characters specified by start and end. Shifts any remaining characters to the left.
| start | the inclusive start index. | 
|---|---|
| end | the exclusive end index. | 
| StringIndexOutOfBoundsException | if startis less than zero, greater than the current length or greater thanend. | 
|---|
Deletes the character at the specified index. shifts any remaining characters to the left.
| index | the index of the character to delete. | 
|---|
| StringIndexOutOfBoundsException | if indexis less than zero or is greater than or equal to the current length. | 
|---|
Ensures that this object has a minimum capacity available before requiring the internal buffer to be enlarged. The general policy of this method is that if the minimumCapacity is larger than the current capacity(), then the capacity will be increased to the largest value of either the minimumCapacity or the current capacity multiplied by two plus two. Although this is the general policy, there is no guarantee that the capacity will change.
| min | the new minimum capacity to set. | 
|---|
Copies the requested sequence of characters into dst passed starting at dst.
| start | the inclusive start index of the characters to copy. | 
|---|---|
| end | the exclusive end index of the characters to copy. | 
| dst | the char[]to copy the characters to. | 
| dstStart | the inclusive start index of dstto begin copying to. | 
| IndexOutOfBoundsException | if the startis negative, thedstStartis negative, thestartis greater thanend, theendis greater than the currentlength()ordstStart + end - beginis greater thandst.length. | 
|---|
Searches for the index of the specified character. The search for the character starts at the specified offset and moves towards the end.
| subString | the string to find. | 
|---|---|
| start | the starting offset. | 
Searches for the first index of the specified character. The search for the character starts at the beginning and moves towards the end.
| string | the string to find. | 
|---|
Inserts the string representation of the specified subsequence of the CharSequence at the specified offset. The CharSequence is converted to a String as defined by subSequence(int, int). If the CharSequence is null, then the string "null" is used to determine the subsequence.
| offset | the index to insert at. | 
|---|---|
| s | the CharSequenceto insert. | 
| start | the start of the subsequence of the character sequence. | 
| end | the end of the subsequence of the character sequence. | 
| IndexOutOfBoundsException | if offsetis negative or greater than the currentlength(), orstartandenddo not specify a valid subsequence. | 
|---|
Inserts the string representation of the specified int value at the specified offset. The int value is converted to a String according to the rule defined by valueOf(int).
| offset | the index to insert at. | 
|---|---|
| i | the intvalue to insert. | 
| StringIndexOutOfBoundsException | if offsetis negative or greater than the currentlength(). | 
|---|
Inserts the string representation of the specified double value at the specified offset. The double value is converted to a String according to the rule defined by valueOf(double).
| offset | the index to insert at. | 
|---|---|
| d | the doublevalue to insert. | 
| StringIndexOutOfBoundsException | if offsetis negative or greater than the currentlength(). | 
|---|
Inserts the string representation of the specified subsequence of the char[] at the specified offset. The char[] value is converted to a String according to the rule defined by valueOf(char[], int, int).
| offset | the index to insert at. | 
|---|---|
| str | the char[]to insert. | 
| strOffset | the inclusive index. | 
| strLen | the number of characters. | 
| StringIndexOutOfBoundsException | if offsetis negative or greater than the currentlength(), orstrOffsetandstrLendo not specify a valid subsequence. | 
|---|
Inserts the specified string at the specified offset. If the specified string is null, then the String "null" is inserted.
| offset | the index to insert at. | 
|---|---|
| str | the Stringto insert. | 
| StringIndexOutOfBoundsException | if offsetis negative or greater than the currentlength(). | 
|---|
Inserts the string representation of the specified long value at the specified offset. The long value is converted to a String according to the rule defined by valueOf(long).
| offset | the index to insert at. | 
|---|---|
| l | the longvalue to insert. | 
| StringIndexOutOfBoundsException | if offsetis negative or greater than the current {code length()}. | 
|---|
Inserts the string representation of the specified Object at the specified offset. The Object value is converted to a String according to the rule defined by valueOf(Object).
| offset | the index to insert at. | 
|---|---|
| obj | the Objectto insert. | 
| StringIndexOutOfBoundsException | if offsetis negative or greater than the currentlength(). | 
|---|
Inserts the string representation of the specified float value at the specified offset. The float value is converted to a string according to the rule defined by valueOf(float).
| offset | the index to insert at. | 
|---|---|
| f | the floatvalue to insert. | 
| StringIndexOutOfBoundsException | if offsetis negative or greater than the currentlength(). | 
|---|
Inserts the string representation of the specified char value at the specified offset. The char value is converted to a string according to the rule defined by valueOf(char).
| offset | the index to insert at. | 
|---|---|
| c | the charvalue to insert. | 
| IndexOutOfBoundsException | if offsetis negative or greater than the currentlength(). | 
|---|
Inserts the string representation of the specified char[] at the specified offset. The char[] value is converted to a String according to the rule defined by valueOf(char[]).
| offset | the index to insert at. | 
|---|---|
| ch | the char[]to insert. | 
| StringIndexOutOfBoundsException | if offsetis negative or greater than the currentlength(). | 
|---|
Inserts the string representation of the specified CharSequence at the specified offset. The CharSequence is converted to a String as defined by toString(). If s is null, then the String "null" is inserted.
| offset | the index to insert at. | 
|---|---|
| s | the CharSequenceto insert. | 
| IndexOutOfBoundsException | if offsetis negative or greater than the currentlength(). | 
|---|
Inserts the string representation of the specified boolean value at the specified offset. The boolean value is converted to a string according to the rule defined by valueOf(boolean).
| offset | the index to insert at. | 
|---|---|
| b | the booleanvalue to insert. | 
| StringIndexOutOfBoundsException | if offsetis negative or greater than the currentlength. | 
|---|
Searches for the last index of the specified character. The search for the character starts at the end and moves towards the beginning.
| string | the string to find. | 
|---|
| NullPointerException | if stringisnull. | 
|---|
Searches for the index of the specified character. The search for the character starts at the specified offset and moves towards the beginning.
| subString | the string to find. | 
|---|---|
| start | the starting offset. | 
| NullPointerException | if subStringisnull. | 
|---|
The current length.
Returns the index that is offset codePointOffset code points from index.
| index | the index to calculate the offset from. | 
|---|---|
| codePointOffset | the number of code points to count. | 
codePointOffset code points away from index.| IndexOutOfBoundsException | if indexis negative or greater thanlength()or if there aren't enough code points before or afterindexto matchcodePointOffset. | 
|---|
Replaces the specified subsequence in this builder with the specified string.
| start | the inclusive begin index. | 
|---|---|
| end | the exclusive end index. | 
| string | the replacement string. | 
| StringIndexOutOfBoundsException | if startis negative, greater than the currentlength()or greater thanend. | 
|---|---|
| NullPointerException | if strisnull. | 
Reverses the order of characters in this builder.
Sets the character at the index.
| index | the zero-based index of the character to replace. | 
|---|---|
| ch | the character to set. | 
| IndexOutOfBoundsException | if indexis negative or greater than or equal to the currentlength(). | 
|---|
Sets the current length to a new value. If the new length is larger than the current length, then the new characters at the end of this object will contain the char value of ef="../../../reference/java/lang/String.html">String  toString ()  
 
          
            Added in 
           API level 1
           
         
          
          
           Returns the contents of this builder.
           
           
           Returns
 
           
            - the string representation of the data in this builder. 
         
         
           public void  trimToSize () 
 
          
          
            Added in 
           API level 1
           
          
          
          
           Trims off any extra capacity beyond the current length. Note, this method is NOT guaranteed to change the capacity of this object.