Top Description Fields Constructors Methods
org.apache.groovy.io

public Class StringBuilderWriter

extends Writer
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.Serializable, .Writer

Copied from https://github.com/apache/commons-io/blob/master/src/main/java/org/apache/commons/io/output/StringBuilderWriter.java Writer implementation that outputs to a StringBuilder.

Note

This implementation, as an alternative to java.io.StringWriter, provides an un-synchronized (i.e. for use in a single thread) implementation for better performance. For safe usage with multiple Threads then java.io.StringWriter should be used.

Since
2.0

Field Summary

Modifier and TypeField and Description
private final StringBuilder
private static final long
Inherited from java.io.Writer:
lock

Constructor Summary

AccessConstructor and Description
public
StringBuilderWriter()

Constructs a new StringBuilder instance with default capacity.

public
StringBuilderWriter(final int
The initial capacity of the underlying StringBuilder
capacity
)

Constructs a new StringBuilder instance with the specified capacity.

public
StringBuilderWriter(final StringBuilder
The String builder. May be null.
builder
)

Constructs a new instance with the specified StringBuilder.

Method Summary

Modifier and TypeMethod and Description
public Writer

Returns:

This writer instance
append
(final char
The character to append
value
)

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Appends a single character to this Writer.
public Writer

Returns:

This writer instance
append
(final CharSequence
The character to append
value
)

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Appends a character sequence to this Writer.
public Writer

Returns:

This writer instance
append
(final CharSequence
The character to append
value
,
final int
The index of the first character
start
,
final int
The index of the last character + 1
end
)

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Appends a portion of a character sequence to the StringBuilder.
public void
close()

Implements abstract java.io.Writer.close.

Implements java.io.Closeable.close.

Closing this writer has no effect.
public void
flush()

Implements abstract java.io.Writer.flush.

Implements java.io.Flushable.flush.

Flushing this writer has no effect.
public StringBuilder

Returns:

The underlying builder
getBuilder
()

Returns the underlying builder.

public String

Returns:

The contents of the String builder.
toString
()

Overrides java.lang.Object.toString.

Returns StringBuilder#toString().
public void
write(final String
The value to write
value
)

Overrides java.io.Writer.write.

Writes a String to the StringBuilder.
public void
write(final char[]
The value to write
value
,
final int
The index of the first character
offset
,
final int
The number of characters to write
length
)

Implements abstract java.io.Writer.write.

Writes a portion of a character array to the StringBuilder.
Inherited from java.io.Writer:
nullWriterwritewritewrite

Field Detail

builderback to summary
private final StringBuilder builder
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

StringBuilderWriterback to summary
public StringBuilderWriter()

Constructs a new StringBuilder instance with default capacity.

StringBuilderWriterback to summary
public StringBuilderWriter(final int capacity)

Constructs a new StringBuilder instance with the specified capacity.

Parameters
capacity:int

The initial capacity of the underlying StringBuilder

StringBuilderWriterback to summary
public StringBuilderWriter(final StringBuilder builder)

Constructs a new instance with the specified StringBuilder.

If builder is null a new instance with default capacity will be created.

Parameters
builder:StringBuilder

The String builder. May be null.

Method Detail

appendback to summary
public Writer append(final char value)

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Appends a single character to this Writer.

Parameters
value:char

The character to append

Returns:Writer

This writer instance

Annotations
@Override
appendback to summary
public Writer append(final CharSequence value)

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Appends a character sequence to this Writer.

Parameters
value:CharSequence

The character to append

Returns:Writer

This writer instance

Annotations
@Override
appendback to summary
public Writer append(final CharSequence value, final int start, final int end)

Overrides java.io.Writer.append.

Implements java.lang.Appendable.append.

Appends a portion of a character sequence to the StringBuilder.

Parameters
value:CharSequence

The character to append

start:int

The index of the first character

end:int

The index of the last character + 1

Returns:Writer

This writer instance

Annotations
@Override
closeback to summary
public void close()

Implements abstract java.io.Writer.close.

Implements java.io.Closeable.close.

Closing this writer has no effect.

Annotations
@Override
flushback to summary
public void flush()

Implements abstract java.io.Writer.flush.

Implements java.io.Flushable.flush.

Flushing this writer has no effect.

Annotations
@Override
getBuilderback to summary
public StringBuilder getBuilder()

Returns the underlying builder.

Returns:StringBuilder

The underlying builder

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns StringBuilder#toString().

Returns:String

The contents of the String builder.

Annotations
@Override
writeback to summary
public void write(final String value)

Overrides java.io.Writer.write.

Writes a String to the StringBuilder.

Parameters
value:String

The value to write

Annotations
@Override
writeback to summary
public void write(final char[] value, final int offset, final int length)

Implements abstract java.io.Writer.write.

Writes a portion of a character array to the StringBuilder.

Parameters
value:char[]

The value to write

offset:int

The index of the first character

length:int

The number of characters to write

Annotations
@Override