public final class BlockWriter extends PrintWriter
out
Constructor and Description |
---|
BlockWriter(OutputStream out) |
BlockWriter(OutputStream out,
boolean autoFlush) |
BlockWriter(Writer out) |
BlockWriter(Writer out,
boolean autoFlush) |
Modifier and Type | Method and Description |
---|---|
static BlockWriter |
create()
Creates a new, empty BlockWriter with a StringWriter as the buffer.
|
static BlockWriter |
create(int initialSize)
Creates a new, empty BlockWriter with a StringWriter as the buffer.
|
void |
endBlock()
Ends a block.
|
int |
getBlockDepth()
Returns how deep the number of blocks is.
|
StringWriter |
getBuffer()
If this object has been created using
create() , returns the StringWriter output buffer. |
String |
getPrependNewlineString()
Returns the string being prepended to new lines, if set.
|
boolean |
isEmpty()
Returns true if nothing has been written to the stream yet.
|
void |
printBlock(Object blockText)
Alias for
writeBlock(Object) . |
void |
println() |
BlockWriter |
setPrependNewlineString(String prependNewLineString)
Sets the string to prepend to new lines.
|
BlockWriter |
setPrependNewlineString(String prependNewLineString,
boolean skipFirstLine)
Sets the string to prepend to new lines.
|
void |
startBlock()
Starts a new block.
|
String |
toString()
If this object has been created using
create() , this will return the contents
of the StringWriter buffer. |
void |
write(char[] cbuf,
int off,
int len) |
void |
write(int c) |
void |
write(String s,
int off,
int len) |
void |
writeBlock(Object blockText)
Writes an entire block in one go.
|
append, append, append, checkError, clearError, close, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, setError, write, write
public BlockWriter(Writer out)
public BlockWriter(Writer out, boolean autoFlush)
public BlockWriter(OutputStream out)
public BlockWriter(OutputStream out, boolean autoFlush)
public static BlockWriter create()
toString()
public static BlockWriter create(int initialSize)
initialSize
- Initialize the output buffer to the specified size.toString()
public void write(int c)
write
in class PrintWriter
public void write(char[] cbuf, int off, int len)
write
in class PrintWriter
public void write(String s, int off, int len)
write
in class PrintWriter
public void println()
println
in class PrintWriter
public void startBlock()
endBlock()
is called when the block is completed.public void endBlock()
public void writeBlock(Object blockText)
blockText
- The text of the block.public void printBlock(Object blockText)
writeBlock(Object)
.blockText
- The text of the block.public int getBlockDepth()
0
means that no blocks are currently active.public boolean isEmpty()
public StringWriter getBuffer()
create()
, returns the StringWriter output buffer.public String getPrependNewlineString()
public BlockWriter setPrependNewlineString(String prependNewLineString)
prependNewLineString
- The string to prepend to each new line.public BlockWriter setPrependNewlineString(String prependNewLineString, boolean skipFirstLine)
setPrependNewlineString(String)
.prependNewLineString
- The string to prepend to each new line.skipFirstLine
- If true, the first line won't be prepended.Copyright © 2017. All rights reserved.