public class CharBuffer extends Object
Constructor and Description |
---|
CharBuffer()
Creates a new CharBuffer with an initial capacity of 32 characters.
|
CharBuffer(int length)
Creates a new CharBuffer with an initial capacity
of
length characters. |
Modifier and Type | Method and Description |
---|---|
void |
append(char data)
Appends a single character to the end of this CharBuffer.
|
void |
append(char[] data)
Appends
data to the end of this CharBuffer. |
void |
append(CharBuffer cb)
Appends the contents of
cb to the end of this CharBuffer. |
void |
append(String s)
Appends
s to the end of this CharBuffer. |
void |
append(StringBuffer sb)
Appends
sb to the end of this CharBuffer. |
int |
capacity()
Returns the current capacity of the buffer.
|
char |
charAt(int pos)
Returns the character at the specified position.
|
void |
clear()
Empties the buffer.
|
char[] |
getCharacters()
Returns the contents of the buffer as a char[].
|
int |
length()
Returns the number of characters in the buffer.
|
void |
provideCapacity(int capacity)
Copies the data into a new array of at least
capacity size. |
void |
shrink()
Shrinks the capacity of the buffer to the current length if necessary.
|
String |
toString()
Converts the contents of the buffer into a StringBuffer.
|
void |
trimTrailingWhitespace()
Removes trailing whitespace.
|
public CharBuffer()
public CharBuffer(int length)
length
characters.public void clear()
public int length()
public int capacity()
public void append(CharBuffer cb)
cb
to the end of this CharBuffer.cb
- the CharBuffer to append or nullpublic void append(String s)
s
to the end of this CharBuffer.
This method involves copying the new data once!s
- the String to append or nullpublic void append(StringBuffer sb)
sb
to the end of this CharBuffer.
This method involves copying the new data once!sb
- the StringBuffer to append or nullpublic void append(char[] data)
data
to the end of this CharBuffer.
This method involves copying the new data once!data
- the char[] to append or nullpublic void append(char data)
data
- the char to appendpublic void shrink()
public void trimTrailingWhitespace()
public char[] getCharacters()
public char charAt(int pos)
public String toString()
public void provideCapacity(int capacity)
capacity
size.Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.