public class FastStringWriter
extends java.io.Writer
This is based on StringWriter but backed by a
StringBuilder instead.
This class is not thread safe.
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.StringBuilder |
builder |
| Constructor and Description |
|---|
FastStringWriter()
Constructs a new
FastStringWriter instance
using the default capacity of 16. |
FastStringWriter(int initialCapacity)
Constructs a new
FastStringWriter instance
using the specified initialCapacity. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
This is a no-op.
|
void |
flush()
This is a no-op.
|
java.lang.StringBuilder |
getBuffer()
Return the
StringBuilder itself. |
void |
reset() |
java.lang.String |
toString() |
void |
write(char[] cbuf,
int off,
int len)
Write a portion of an array of characters.
|
void |
write(java.lang.String str)
Write a string.
|
void |
write(java.lang.String str,
int off,
int len)
Write a portion of a string.
|
public FastStringWriter()
Constructs a new FastStringWriter instance
using the default capacity of 16.
public FastStringWriter(int initialCapacity)
Constructs a new FastStringWriter instance
using the specified initialCapacity.
initialCapacity - specifies the initial capacity of the bufferjava.lang.IllegalArgumentException - if initialCapacity is less than zeropublic void write(char[] cbuf,
int off,
int len)
throws java.io.IOException
Write a portion of an array of characters.
write in class java.io.Writercbuf - Array of charactersoff - Offset from which to start writing characterslen - Number of characters to writejava.io.IOExceptionpublic void flush()
throws java.io.IOException
This is a no-op.
flush in interface java.io.Flushableflush in class java.io.Writerjava.io.IOExceptionpublic void close()
throws java.io.IOException
This is a no-op.
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.Writerjava.io.IOExceptionpublic void write(java.lang.String str)
write in class java.io.Writerstr - String to be writtenpublic void write(java.lang.String str,
int off,
int len)
write in class java.io.Writerstr - A Stringoff - Offset from which to start writing characterslen - Number of characters to writepublic java.lang.StringBuilder getBuffer()
StringBuilder itself.public java.lang.String toString()
toString in class java.lang.Objectpublic void reset()
Copyright ? 2002-2006 Sun Microsystems, Inc. All Rights Reserved.