RoboJDETM v2.0

java.lang
Class StringBuffer

java.lang.Object
  extended by java.lang.StringBuffer

public class StringBuffer
extends Object

Class representing a mutable character string.


Constructor Summary
StringBuffer()
          Constructs an empty StringBuffer and allocates a default length initial buffer.
StringBuffer(int length)
          Constructs an empty StringBuffer and allocates an initial buffer of the length specified.
StringBuffer(String string)
          Constructs a StringBuffer containing the characters in the specified String.
 
Method Summary
 StringBuffer append(boolean b)
          Appends "true" or "false" to this StringBuffer based on the boolean value specified.
 StringBuffer append(char value)
          Appends the specified character to this StringBuffer.
 StringBuffer append(char[] chars)
          Appends the characters from the specified array to this StringBuffer.
 StringBuffer append(char[] chars, int offset, int count)
          Appends the characters from the specified array to this StringBuffer.
 StringBuffer append(double value)
          Appends a string representation of the specified value to this StringBuffer.
 StringBuffer append(float f)
          Appends a string represetation of the specified value to this StringBuffer.
 StringBuffer append(int value)
          Appends a string represetation of the specified value to this StringBuffer.
 StringBuffer append(long value)
          Appends a string represetation of the specified value to this StringBuffer.
 StringBuffer append(Object object)
          Appends the String representation of the specified object to this StringBuffer.
 StringBuffer append(String string)
          Appends the characters from the specified String to this StringBuffer.
 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 StringBuffer.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait
 

Constructor Detail

StringBuffer

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


StringBuffer

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

Parameters:
length - size of buffer to allocate

StringBuffer

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

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

append

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

Parameters:
b - boolean value to append
Returns:
this

append

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

Parameters:
value - character to append
Returns:
this

append

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

Parameters:
chars - character array
Returns:
this

append

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

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

append

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

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

append

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

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

append

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

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

append

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

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

append

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

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

append

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

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 StringBuffer.

Overrides:
toString in class Object
Returns:
String

RoboJDETM v2.0

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