public class CharBuffer extends Object
Constructor and Description |
---|
CharBuffer(int initialCapacity)
Create a new character buffer, specifying its initial capacity.
|
CharBuffer(int initialCapacity,
int minimumGrowth)
Create a new character buffer, specifying its initial capacity and minimum growth.
|
Modifier and Type | Method and Description |
---|---|
void |
buffer(char character)
Add the supplied character to this buffer, growing the buffer if necessary.
|
void |
buffer(char[] characters,
int start,
int length)
Add a section of the supplied character array to this buffer, growing the buffer if necessary.
|
void |
buffer(String text,
int start,
int length)
Add a substring of the supplied string to this buffer, growing the buffer if necessary.
|
void |
clear()
Clear this buffer.
|
int |
getCapacity()
Find the current capacity of this buffer.
|
int |
size()
Obtain the current size of this buffer.
|
char[] |
toArray()
Render this buffer as a character array.
|
String |
toString()
Render this buffer as a String.
|
void |
writeOut(Writer writer)
Write the content of this buffer out to the supplied Writer object.
|
public CharBuffer(int initialCapacity)
initialCapacity
- public CharBuffer(int initialCapacity, int minimumGrowth)
initialCapacity
- The number of characters initially provisioned for.minimumGrowth
- The smallest number of characters by which the buffer will grow.
If zero is specified then the value of the initial capacity will be used.public void buffer(char character)
character
- public void buffer(String text, int start, int length) throws IllegalArgumentException
text
- The original String that is to be added to the buffer.start
- The index of the starting character to add to the buffer (zero-based).length
- The number of characters to add to the buffer.IllegalArgumentException
- If text is null, start points beyond end of text, or start + length
goes beyond end of text.public void buffer(char[] characters, int start, int length) throws IllegalArgumentException
characters
- The character array that is to be added to the buffer.start
- The index of the starting character to add to the buffer (zero-based).length
- The number of characters to add to the buffer.IllegalArgumentException
- If array is null, start points beyond end of array, or start + length
goes beyond end of array.public char[] toArray()
public String toString()
public int getCapacity()
public int size()
toArray()
or the length of String returned by toString()
.public void clear()
size()
will return zero.public void writeOut(Writer writer) throws IOException, IllegalArgumentException
writer
- The writer in to which the buffer should be written.IOException
- If any error occurs while writing the buffer into the stream.IllegalArgumentException
- If 'writer' is null.Copyright © 2016 JBoss by Red Hat. All rights reserved.