RoboJDETM v2.0

java.lang
Class StringBuilder

java.lang.Object
  extended by java.lang.StringBuilder

public class StringBuilder
extends Object

Class representing a mutable character string.


Constructor Summary
StringBuilder()
          Constructs an empty StringBuilder and allocates a default length initial buffer.
StringBuilder(int length)
          Constructs an empty StringBuilder and allocates an initial buffer of the length specified.
StringBuilder(String string)
          Constructs a StringBuilder containing the characters in the specified String.
 
Method Summary
 StringBuilder append(boolean b)
          Appends "true" or "false" to this StringBuilder based on the boolean value specified.
 StringBuilder append(char value)
          Appends the specified character to this StringBuilder.
 StringBuilder append(char[] chars)
          Appends the characters from the specified array to this StringBuilder.
 StringBuilder append(char[] chars, int offset, int count)
          Appends the characters from the specified array to this StringBuilder.
 StringBuilder append(double value)
          Appends a string representation of the specified value to this StringBuilder.
 StringBuilder append(float f)
          Appends a string represetation of the specified value to this StringBuilder.
 StringBuilder append(int value)
          Appends a string represetation of the specified value to this StringBuilder.
 StringBuilder append(long value)
          Appends a string represetation of the specified value to this StringBuilder.
 StringBuilder append(Object object)
          Appends the String representation of the specified object to this StringBuilder.
 StringBuilder append(String string)
          Appends the characters from the specified String to this StringBuilder.
 void ensureCapacity(int minimumLength)
          Ensures the buffer is large enough to hold the minimum length specified.
 int length()
          Returns the current length of the string.
 void setLength(int newLength)
          Sets the length of the string.
 String toString()
          Returns a String containing the character sequence in this StringBuilder.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait
 

Constructor Detail

StringBuilder

public StringBuilder()
Constructs an empty StringBuilder and allocates a default length initial buffer.


StringBuilder

public StringBuilder(int length)
Constructs an empty StringBuilder and allocates an initial buffer of the length specified.

Parameters:
length - size of buffer to allocate

StringBuilder

public StringBuilder(String string)
Constructs a StringBuilder containing the characters in the specified String.

Parameters:
string - String to initialize the buffer from
Method Detail

append

public StringBuilder append(boolean b)
Appends "true" or "false" to this StringBuilder based on the boolean value specified.

Parameters:
b - boolean value to append
Returns:
this

append

public StringBuilder append(char value)
Appends the specified character to this StringBuilder.

Parameters:
value - character to append
Returns:
this

append

public StringBuilder append(char[] chars)
Appends the characters from the specified array to this StringBuilder.

Parameters:
chars - character array
Returns:
this

append

public StringBuilder append(char[] chars,
                            int offset,
                            int count)
Appends the characters from the specified array to this StringBuilder.

Parameters:
chars - character array
offset - starting offset in array
count - characters to take from array
Returns:
this

append

public StringBuilder append(double value)
Appends a string representation of the specified value to this StringBuilder.

Parameters:
value - value whose string representation is to be appended
Returns:
this

append

public StringBuilder append(float f)
Appends a string represetation of the specified value to this StringBuilder.

Parameters:
f - value whose string representation is to be appended
Returns:
this

append

public StringBuilder append(int value)
Appends a string represetation of the specified value to this StringBuilder.

Parameters:
value - value whose string representation is to be appended
Returns:
this

append

public StringBuilder append(long value)
Appends a string represetation of the specified value to this StringBuilder.

Parameters:
value - value whose string representation is to be appended
Returns:
this

append

public StringBuilder append(Object object)
Appends the String representation of the specified object to this StringBuilder.

Parameters:
object - object whose string representation is to be appended
Returns:
this

append

public StringBuilder append(String string)
Appends the characters from the specified String to this StringBuilder.

Parameters:
string - string to append
Returns:
this

ensureCapacity

public void ensureCapacity(int minimumLength)
Ensures the buffer is large enough to hold the minimum length specified. If it is not, the buffer is enlarged.

Parameters:
minimumLength - minimum size buffer

length

public int length()
Returns the current length of the string.

Returns:
length in characters

setLength

public void setLength(int newLength)
Sets the length of the string. If the string in the buffer is longer then the specified length it is truncated to the new length. If the new length is longer than the old length, null characters are append to the string to extend it to the new length.

Parameters:
newLength - new length
Throws:
IndexOutOfBoundsException - if newLength < 0

toString

public String toString()
Returns a String containing the character sequence in this StringBuilder.

Overrides:
toString in class Object
Returns:
String

RoboJDETM v2.0

Copyright (c) 2003-2009 RidgeSoft, LLC. All rights reserved.
www.ridgesoft.com