java.lang.Object
org.miaixz.bus.setting.metric.toml.TomlWriter
A writer for generating TOML (Tom's Obvious, Minimal Language) data from a Map.
Supported date/time types for writing:
LocalDate(e.g., 2015-03-20)LocalDateTime(e.g., 2015-03-20T19:04:35)ZonedDateTime(e.g., 2015-03-20T19:04:35+01:00)
This writer supports bare keys consisting of A-Za-z0-9_-. Any other keys will be enclosed in double quotes.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
ConstructorsConstructorDescriptionTomlWriter(Writer writer) Creates a new TomlWriter with default parameters.TomlWriter(Writer writer, int indentSize, boolean indentWithSpaces) Creates a new TomlWriter with specified indentation parameters.TomlWriter(Writer writer, int indentSize, boolean indentWithSpaces, String lineSeparator) Creates a new TomlWriter with the specified parameters. -
Method Summary
-
Constructor Details
-
TomlWriter
Creates a new TomlWriter with default parameters. The system line separator is used. This is equivalent toTomlWriter(writer, 1, false, System.lineSeparator()).- Parameters:
writer- where to write the data
-
TomlWriter
Creates a new TomlWriter with specified indentation parameters. The system line separator is used. This is equivalent toTomlWriter(writer, indentSize, indentWithSpaces, System.lineSeparator()).- Parameters:
writer- where to write the dataindentSize- the number of characters for each indent levelindentWithSpaces- true to indent with spaces, false to indent with tabs
-
TomlWriter
Creates a new TomlWriter with the specified parameters.- Parameters:
writer- where to write the dataindentSize- the number of characters for each indent levelindentWithSpaces- true to indent with spaces, false to indent with tabslineSeparator- the string to use for line breaks
-
-
Method Details
-
close
Closes the underlying writer, flushing it first.- Throws:
IOException- if an I/O error occurs
-
flush
Flushes the underlying writer.- Throws:
IOException- if an I/O error occurs
-
write
public void write(Map<String, Object> data) throws org.miaixz.bus.core.lang.exception.InternalExceptionWrites the specified data map to the writer in TOML format.- Parameters:
data- the data to write- Throws:
org.miaixz.bus.core.lang.exception.InternalException- if an I/O error occurs during writing
-