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.Writer
cbuf
- Array of charactersoff
- Offset from which to start writing characterslen
- Number of characters to writejava.io.IOException
public void flush() throws java.io.IOException
This is a no-op.
flush
in interface java.io.Flushable
flush
in class java.io.Writer
java.io.IOException
public void close() throws java.io.IOException
This is a no-op.
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.Writer
java.io.IOException
public void write(java.lang.String str)
write
in class java.io.Writer
str
- String to be writtenpublic void write(java.lang.String str, int off, int len)
write
in class java.io.Writer
str
- 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.Object
public void reset()
Copyright ? 2002-2006 Sun Microsystems, Inc. All Rights Reserved.