public class IndentingWriter extends Writer
Writer with support for indenting.| Constructor and Description |
|---|
IndentingWriter(Writer out)
Create a new instance with the specified writer using a default
indent strategy of 4 spaces.
|
IndentingWriter(Writer out,
Function<Integer,String> indentStrategy)
Create a new instance with the specified writer and indent
strategy.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
flush() |
void |
indented(Runnable runnable)
Increase the indentation level and execute the
Runnable. |
void |
print(String string)
Write the specified text.
|
void |
println()
Write a new line.
|
void |
println(String string)
Write the specified text and append a new line.
|
void |
write(char[] chars,
int offset,
int length) |
public IndentingWriter(Writer out)
out - the writer to usepublic void print(String string)
string - the content to writepublic void println(String string)
string - the content to writepublic void println()
public void indented(Runnable runnable)
Runnable. Decrease the
indentation level on completion.runnable - the code to execute withing an extra indentation levelpublic void flush()
throws IOException
flush in interface Flushableflush in class WriterIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class WriterIOExceptionCopyright © 2021 Pivotal Software, Inc.. All rights reserved.