Module bus.setting

Class TomlWriter

java.lang.Object
org.miaixz.bus.setting.metric.toml.TomlWriter

public class TomlWriter extends Object
TOML生成器

日期格式支持:

此类支持更加宽松的key,除了A-Za-z0-9_- ,其他key使用"包装。

Since:
Java 17+
Author:
Kimi Liu
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new TomlWriter with the defaults parameters.
    TomlWriter(Writer writer, int indentSize, boolean indentWithSpaces)
    Creates a new TomlWriter with the specified parameters.
    TomlWriter(Writer writer, int indentSize, boolean indentWithSpaces, String lineSeparator)
    Creates a new TomlWriter with the specified parameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the underlying writer, flushing it first.
    void
    Flushes the underlying writer.
    void
    Writes the specified data in the TOML format.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TomlWriter

      public TomlWriter(Writer writer)
      Creates a new TomlWriter with the defaults parameters. The system line separator is used (ie '\n' on Linux and OSX, "\r\n" on Windows). This is exactly the same as TomlWriter(writer, 1, false, System.lineSeparator().
      Parameters:
      writer - where to write the data
    • TomlWriter

      public TomlWriter(Writer writer, int indentSize, boolean indentWithSpaces)
      Creates a new TomlWriter with the specified parameters. The system line separator is used (ie '\n' on Linux and OSX, "\r\n" on Windows). This is exactly the same as TomlWriter(writer, indentSize, indentWithSpaces, System.lineSeparator()).
      Parameters:
      writer - where to write the data
      indentSize - the size of each indent
      indentWithSpaces - true to indent with spaces, false to indent with tabs
    • TomlWriter

      public TomlWriter(Writer writer, int indentSize, boolean indentWithSpaces, String lineSeparator)
      Creates a new TomlWriter with the specified parameters.
      Parameters:
      writer - where to write the data
      indentSize - the size of each indent
      indentWithSpaces - true to indent with spaces, false to indent with tabs
      lineSeparator - the String to write to break lines
  • Method Details

    • close

      public void close() throws IOException
      Closes the underlying writer, flushing it first.
      Throws:
      IOException - if an error occurs
    • flush

      public void flush() throws IOException
      Flushes the underlying writer.
      Throws:
      IOException - if an error occurs
    • write

      public void write(Map<String,Object> data) throws org.miaixz.bus.core.lang.exception.InternalException
      Writes the specified data in the TOML format.
      Parameters:
      data - the data to write
      Throws:
      org.miaixz.bus.core.lang.exception.InternalException - if an error occurs