public class TomlWriter extends Object
Converts Objects to TOML
An input Object can comprise arbitrarily nested combinations of Java primitive types,
other Objects, Maps, Lists, and Arrays. Objects and Maps
are output to TOML tables, and Lists and Array to TOML arrays.
Example usage:
class AClass {
int anInt = 1;
int[] anArray = { 2, 3 };
}
String tomlString = new TomlWriter().write(new AClass());
| Modifier and Type | Class and Description |
|---|---|
static class |
TomlWriter.Builder |
| Constructor and Description |
|---|
TomlWriter()
Creates a TomlWriter instance.
|
| Modifier and Type | Method and Description |
|---|---|
String |
write(Object from)
Write an Object into TOML String.
|
void |
write(Object from,
File target)
Write an Object in TOML to a
File. |
void |
write(Object from,
OutputStream target)
Write an Object in TOML to a
OutputStream. |
void |
write(Object from,
Writer target)
Write an Object in TOML to a
Writer. |
public String write(Object from)
from - the object to be writtenpublic void write(Object from, File target) throws IOException
File. Output is encoded as UTF-8.from - the object to be writtentarget - the File to which the TOML will be writtenIOException - if any file operations failpublic void write(Object from, OutputStream target) throws IOException
OutputStream. Output is encoded as UTF-8.from - the object to be writtentarget - the OutputStream to which the TOML will be written. The stream is NOT closed after being written to.IOException - if target.write() failspublic void write(Object from, Writer target) throws IOException
Writer. You MUST ensure that the Writers's encoding is set to UTF-8 for the TOML to be valid.from - the object to be written. Can be a Map or a custom type. Must not be null.target - the Writer to which TOML will be written. The Writer is not closed.IOException - if target.write() failsIllegalArgumentException - if from is of an invalid typeCopyright © 2013–2017. All rights reserved.