| 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--java.lang.StringBuffer
The StringBuffer class represents strings of characters which can change at runtime. A StringBuffer will grow dynamically as its contents change. Growing the StringBuffer requires allocating an entirely new buffer and copying the old string to the new buffer. This can result in a lot of unused memory so it is recommended that when a StringBuffer is created the maximum length is specified.
| Constructor Summary | |
StringBuffer()
Allocate a new empty StringBuffer using the default capacity of 64 characters.  | 
|
StringBuffer(int capacity)
Allocate a new empty StringBuffer using the specified capacity.  | 
|
StringBuffer(String value)
Allocate a new StringBuffer and copy its contents from a String.  | 
|
| Method Summary | |
 StringBuffer | 
append(char c)
Append a character to the StringBuffer.  | 
 StringBuffer | 
append(char[] str,
       int length)
Append an array of characters to a StringBuffer.  | 
 StringBuffer | 
append(int val)
Append the string value of an integer to the StringBuffer.  | 
 StringBuffer | 
append(String str)
Append a String to the StringBuffer.  | 
 int | 
capacity()
Returns the current capacity of the StringBuffer.  | 
 char | 
charAt(int index)
Retrieve a character from StringBuffer.  | 
 void | 
clear()
Clear the content of StringBuffer.  | 
 StringBuffer | 
delete(int start,
       int end)
Delete a range of characters from the StringBuffer.  | 
 boolean | 
equals(String sb)
Compare this StringBuffer to a String to see if they contain the identical sequence of characters.  | 
 boolean | 
equals(StringBuffer sb)
Compare this StringBuffer to another to see if they contain the identical sequence of characters.  | 
 int | 
indexOf(String str)
Finds the first occurance of the specified String in this StringBuffer.  | 
 StringBuffer | 
insert(int offset,
       char c)
Insert a character into a StringBuffer.  | 
 int | 
length()
Returns the current length of the StringBuffer.  | 
 StringBuffer | 
subString(int start,
          int end)
Extract a substring from the StringBuffer into a new StringBuffer.  | 
 void | 
subString(int start,
          int end,
          StringBuffer dest)
Extract a substring from the StringBuffer into a existing StringBuffer.  | 
 String | 
toNewString()
Convert the StringBuffer to a string by allocating a new String object.  | 
 String | 
toString()
Convert the StringBuffer to a string.  | 
| Methods inherited from class java.lang.Object | 
equals | 
| Constructor Detail | 
public StringBuffer()
public StringBuffer(int capacity)
capacity - the capacity of the new StringBuffer.public StringBuffer(String value)
value - the String to copy into the StringBuffer.| Method Detail | 
public int length()
public int capacity()
public void clear()
public StringBuffer delete(int start,
                           int end)
start - index of the first character to delete.end - index of the character after the last character to delete.public StringBuffer append(String str)
str - the String to append.the - StringBuffer.public StringBuffer append(char c)
c - the character to append.the - StringBuffer.public StringBuffer append(int val)
val - the integer val to append.the - StringBuffer.
public StringBuffer append(char[] str,
                           int length)
str - the array to append.length - the number of characters from str to append.
public StringBuffer insert(int offset,
                           char c)
                    throws IndexOutOfBoundsException
offset - the index to insert the character at.c - the character to insert.public String toString()
public String toNewString()
public boolean equals(StringBuffer sb)
sb - the StringBuffer to compare to.public boolean equals(String sb)
sb - the String to compare to.
public char charAt(int index)
            throws IndexOutOfBoundsException
index - the index into the StringBuffer of the character to retrieve.
    Indexes start at 0 and end at length()-1.
public StringBuffer subString(int start,
                              int end)
start - the index of the first character in the substring.end - the index of the character after the last character in the
   substring.
public void subString(int start,
                      int end,
                      StringBuffer dest)
start - the index of the first character in the substring.end - the index of the character after the last character in the
   substring.dest - the Stringbuffer to place the substring in. Any existing content
   in dest is overwritten.public int indexOf(String str)
str - the String to search for.
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||