Package com.sun.faces.io
Class FastStringWriter
java.lang.Object
java.io.Writer
com.sun.faces.io.FastStringWriter
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
public class FastStringWriter extends Writer
This is based on StringWriter
but backed by a StringBuilder
instead.
This class is not thread safe.
-
Field Summary
Fields Modifier and Type Field Description protected StringBuilder
builder
-
Constructor Summary
Constructors Constructor Description FastStringWriter()
Constructs a newFastStringWriter
instance using the default capacity of16
.FastStringWriter(int initialCapacity)
Constructs a newFastStringWriter
instance using the specifiedinitialCapacity
. -
Method Summary
Modifier and Type Method Description void
close()
This is a no-op.void
flush()
This is a no-op.StringBuilder
getBuffer()
Return theStringBuilder
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.
-
Field Details
-
Constructor Details
-
FastStringWriter
public FastStringWriter()Constructs a new
FastStringWriter
instance using the default capacity of16
. -
FastStringWriter
public FastStringWriter(int initialCapacity)Constructs a new
FastStringWriter
instance using the specifiedinitialCapacity
.- Parameters:
initialCapacity
- specifies the initial capacity of the buffer- Throws:
IllegalArgumentException
- if initialCapacity is less than zero
-
-
Method Details
-
write
Write a portion of an array of characters.
- Specified by:
write
in classWriter
- Parameters:
cbuf
- Array of charactersoff
- Offset from which to start writing characterslen
- Number of characters to write- Throws:
IOException
-
flush
This is a no-op.
- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in classWriter
- Throws:
IOException
-
close
This is a no-op.
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
-
write
Write a string. -
write
Write a portion of a string. -
getBuffer
Return theStringBuilder
itself.- Returns:
- StringBuilder holding the current buffer value.
-
toString
-
reset
public void reset()
-