java.lang.Object
java.io.Writer
i2p.susi.util.StringBuilderWriter
- All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable
Writer implementation backed by StringBuilder.
Field Summary
FieldsConstructor Summary
ConstructorsConstructorDescriptionCreate a StringBuilderWriter with default capacity.StringBuilderWriter(int capacity) Create a StringBuilderWriter with specified capacity.Method Summary
All MethodsModifier and TypeMethodDescriptionappend(char c) Append a character.append(CharSequence str) Append a character sequence.append(CharSequence str, int off, int len) Append a portion of a character sequence.voidclose()Does nothing.voidflush()Does nothing.Get the underlying StringBuilder.toString()voidwrite(char[] cbuf) Write a character array.voidwrite(char[] cbuf, int off, int len) Write a portion of a character array.voidwrite(int c) Write a single character.voidWrite a string.voidWrite a portion of a string.Methods inherited from class Writer
nullWriter
Field Details
buf
The builder this writer appends to.
Constructor Details
StringBuilderWriter
public StringBuilderWriter()Create a StringBuilderWriter with default capacity.StringBuilderWriter
public StringBuilderWriter(int capacity) Create a StringBuilderWriter with specified capacity.- Parameters:
capacity- the initial capacity
Method Details
append
Append a character.- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- Parameters:
c- the character to append- Returns:
- this writer, for chaining
append
Append a character sequence.- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- Parameters:
str- the character sequence to append- Returns:
- this writer, for chaining
append
Append a portion of a character sequence.- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- Parameters:
str- the character sequenceoff- the start offsetlen- the number of characters- Returns:
- this writer, for chaining
write
write
write
write
write
close
flush
getBuilder
Get the underlying StringBuilder.- Returns:
- the builder holding everything written so far, never null
toString