java.lang
Class StringBuffer

java.lang.Object
  extended byjava.lang.StringBuffer

public class StringBuffer
extends Object


Constructor Summary
StringBuffer()
          Constructs an empty string buffer.
StringBuffer(int length)
          Constructs an empty string buffer with the specified capacity.
StringBuffer(String s)
          Constructs a string buffer containing the given string.
 
Method Summary
 StringBuffer append(boolean b)
           
 StringBuffer append(char c)
           
 StringBuffer append(char[] chars)
           
 StringBuffer append(char[] chars, int offset, int length)
           
 StringBuffer append(double d)
           
 StringBuffer append(float f)
           
 StringBuffer append(int i)
           
 StringBuffer append(long l)
           
 StringBuffer append(Object obj)
           
 StringBuffer append(String s)
           
 int capacity()
           
 char charAt(int index)
           
 StringBuffer delete(int start, int end)
          Remove characters from the StringBuffer..
 StringBuffer deleteCharAt(int index)
           
 void ensureCapacity(int minimumCapacity)
          Make sure that the StringBuffer's capacity is at least as large as minimumCapacity.
 void getChars(int srcBegin, int srcEnd, char[] dest, int destBegin)
           
 StringBuffer insert(int index, boolean value)
           
 StringBuffer insert(int index, char value)
           
 StringBuffer insert(int index, char[] chars)
           
 StringBuffer insert(int index, char[] ch, int offset, int length)
           
 StringBuffer insert(int index, double value)
           
 StringBuffer insert(int index, float value)
           
 StringBuffer insert(int index, int value)
           
 StringBuffer insert(int index, long value)
           
 StringBuffer insert(int index, Object value)
           
 StringBuffer insert(int index, String string)
           
 int length()
          Returns the number of characters added to the StringBuffer.
 StringBuffer replace(int start, int end, String str)
           
 StringBuffer reverse()
           
 void setCharAt(int index, char ch)
           
 void setLength(int length)
          Set the length of the StringBuffer.
 String substring(int start)
          Return a new String that contains the characters in the StringBuffer from start to the end of the StringBuffer
 String substring(int start, int end)
          Return a new String that contains the characters in the StringBuffer from start to end-1.
 String toString()
          Convert the added characters to a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode
 

Constructor Detail

StringBuffer

public StringBuffer()
Constructs an empty string buffer.


StringBuffer

public StringBuffer(String s)
Constructs a string buffer containing the given string.


StringBuffer

public StringBuffer(int length)
Constructs an empty string buffer with the specified capacity.

Method Detail

append

public StringBuffer append(String s)

append

public StringBuffer append(char[] chars)

append

public StringBuffer append(char[] chars,
                           int offset,
                           int length)

append

public StringBuffer append(boolean b)

append

public StringBuffer append(char c)

append

public StringBuffer append(int i)

append

public StringBuffer append(float f)

append

public StringBuffer append(double d)

append

public StringBuffer append(long l)

append

public StringBuffer append(Object obj)

length

public int length()
Returns the number of characters added to the StringBuffer.


toString

public String toString()
Convert the added characters to a String.

Overrides:
toString in class Object
Returns:
a String representing this object.

substring

public String substring(int start,
                        int end)
Return a new String that contains the characters in the StringBuffer from start to end-1.

Parameters:
start - The index of the first character - inclusive.
end - The index of the last character - exclusive
Returns:
a new String that contains the characters in the StringBuffer from start to end-1.

substring

public String substring(int start)
Return a new String that contains the characters in the StringBuffer from start to the end of the StringBuffer

Parameters:
start - The index of the first character - inclusive.
Returns:
a new String that contains the characters in the StringBuffer from start to the end of the StringBuffer

ensureCapacity

public void ensureCapacity(int minimumCapacity)
Make sure that the StringBuffer's capacity is at least as large as minimumCapacity.


setLength

public void setLength(int length)
Set the length of the StringBuffer. If the current length is less than the specified length, then sufficient null characters (0) will be appended to make it up to the specified length. If the current length is greater than the specified length then the StringBuffer is truncated to the specified length.

Parameters:
length - The new length.

setCharAt

public void setCharAt(int index,
                      char ch)

reverse

public StringBuffer reverse()

getChars

public void getChars(int srcBegin,
                     int srcEnd,
                     char[] dest,
                     int destBegin)

delete

public StringBuffer delete(int start,
                           int end)
Remove characters from the StringBuffer..

Parameters:
start - The index of the first character - inclusive.
end - The index of the last character - exclusive
Returns:
a new String that contains the characters in the StringBuffer from start to end-1.

deleteCharAt

public StringBuffer deleteCharAt(int index)

charAt

public char charAt(int index)

capacity

public int capacity()

insert

public StringBuffer insert(int index,
                           char[] ch,
                           int offset,
                           int length)

insert

public StringBuffer insert(int index,
                           String string)

insert

public StringBuffer insert(int index,
                           char[] chars)

insert

public StringBuffer insert(int index,
                           boolean value)

insert

public StringBuffer insert(int index,
                           double value)

insert

public StringBuffer insert(int index,
                           float value)

insert

public StringBuffer insert(int index,
                           int value)

insert

public StringBuffer insert(int index,
                           long value)

insert

public StringBuffer insert(int index,
                           Object value)

insert

public StringBuffer insert(int index,
                           char value)

replace

public StringBuffer replace(int start,
                            int end,
                            String str)