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:
flush
in interfaceFlushable
- Specified by:
flush
in classWriter
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
-