public class FastStringWriter extends 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 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.
|
StringBuilder |
getBuffer()
Return the
StringBuilder itself. |
void |
reset() |
String |
toString() |
void |
write(char[] cbuf,
int off,
int len)
Write a portion of an array of characters.
|
void |
write(String str)
Write a string.
|
void |
write(String str,
int off,
int len)
Write a portion of a string.
|
protected StringBuilder builder
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 bufferIllegalArgumentException - if initialCapacity is less than zeropublic void write(char[] cbuf,
int off,
int len)
throws IOException
Write a portion of an array of characters.
write in class Writercbuf - Array of charactersoff - Offset from which to start writing characterslen - Number of characters to writeIOExceptionpublic void flush()
throws IOException
This is a no-op.
flush in interface Flushableflush in class WriterIOExceptionpublic void close()
throws IOException
This is a no-op.
close in interface Closeableclose in interface AutoCloseableclose in class WriterIOExceptionpublic void write(String str)
public void write(String str, int off, int len)
public StringBuilder getBuffer()
StringBuilder itself.public String toString()
public void reset()
Copyright © 2010–2020 JBoss by Red Hat. All rights reserved.