Class IndentingWriter
java.lang.Object
java.io.Writer
io.spring.initializr.generator.io.IndentingWriter
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
A
Writer with support for indenting.- Author:
- Andy Wilkinson
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionIndentingWriter(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. -
Method Summary
-
Constructor Details
-
IndentingWriter
Create a new instance with the specified writer using a default indent strategy of 4 spaces.- Parameters:
out- the writer to use
-
IndentingWriter
Create a new instance with the specified writer and indent strategy.- Parameters:
out- the writer to useindentStrategy- a function that provides the ident to use based on a indentation level
-
-
Method Details
-
print
Write the specified text.- Parameters:
string- the content to write
-
println
Write the specified text and append a new line.- Parameters:
string- the content to write
-
println
public void println()Write a new line. -
indented
Increase the indentation level and execute theRunnable. Decrease the indentation level on completion.- Parameters:
runnable- the code to execute withing an extra indentation level
-
write
public void write(char[] chars, int offset, int length) -
flush
- Specified by:
flushin interfaceFlushable- Specified by:
flushin classWriter- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classWriter- Throws:
IOException
-