|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.Writer org.xins.common.io.FastStringWriter
A non-synchronized equivalent of StringWriter
. This class
implements a character stream that collects its output in a fast,
unsynchronized string buffer, which can then be used to construct a string.
Instances of this class are not thread-safe.
Field Summary |
Fields inherited from class java.io.Writer |
lock |
Constructor Summary | |
FastStringWriter()
Creates a new FastStringWriter using a default initial
internal buffer size. |
|
FastStringWriter(int initialSize)
Creates a new FastStringWriter using a specified initial
string buffer size. |
Method Summary | |
void |
close()
Closes this writer. |
void |
flush()
Flushes this writer. |
FastStringBuffer |
getBuffer()
Returns the underlying string buffer itself. |
String |
toString()
Returns the current value of the underlying buffer as a string. |
void |
write(char[] cbuf)
Writes an array of characters. |
void |
write(char[] cbuf,
int off,
int len)
Writes a portion of an array of characters. |
void |
write(int c)
Writes a single character. |
void |
write(String str)
Writes a character string. |
void |
write(String str,
int off,
int len)
Writes a portion of a character string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public FastStringWriter()
FastStringWriter
using a default initial
internal buffer size.
public FastStringWriter(int initialSize) throws IllegalArgumentException
FastStringWriter
using a specified initial
string buffer size.
initialSize
- the initial size of the buffer, must be >= 0.
IllegalArgumentException
- if initialSize < 0
.Method Detail |
public void write(int c) throws IOException
c
- the character to write.
IOException
- if this writer has been closed (see close()
).public void write(char[] cbuf) throws IOException, IllegalArgumentException
cbuf
- the array of characters to write, cannot be null
.
IOException
- if this writer has been closed (see close()
).
IllegalArgumentException
- if cbuf == null
.public void write(char[] cbuf, int off, int len) throws IllegalArgumentException, IOException, IndexOutOfBoundsException
cbuf
- the array of characters to write a portion of, cannot be
null
.off
- offset from which to start writing characters, must be >= 0 and
< sbuf.length
.len
- the number of characters to write.
IOException
- if this writer has been closed (see close()
).
IllegalArgumentException
- if cbuf == null
.
IndexOutOfBoundsException
- if the offset and/or the length is invalid.public void write(String str) throws IOException, IllegalArgumentException
str
- the character string to write, cannot be null
.
IOException
- if this writer has been closed (see close()
).
IllegalArgumentException
- if str == null
.public void write(String str, int off, int len) throws IllegalArgumentException, IOException, IndexOutOfBoundsException
str
- the character string to write a portion of, cannot be
null
.off
- offset from which to start writing characters, must be >= 0 and
< str.length()
.len
- the number of characters to write.
IOException
- if this writer has been closed (see close()
).
IllegalArgumentException
- if str == null
.
IndexOutOfBoundsException
- if the offset and/or the length is invalid.public void flush() throws IOException
The implementation of this method does not nothing except checking that this writer is not yet closed.
IOException
- if this writer has been closed (see close()
).public void close()
IOException
if called.
Calling this method on a FastStringWriter
after use is
really optional.
public String toString()
null
.public FastStringBuffer getBuffer()
null
.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |