<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-toml</artifactId>
<version>2.11.2</version>
</dependency>
toml
# app.toml
title = "MyApp"
version = "1.0.0"
debug = true
import com.fasterxml.jackson.dataformat.toml.TomlMapper;
public class AppConfig {
private String title;
private String version;
private boolean debug;
// getter and setter methods
public static AppConfig fromTomlFile(String filePath) throws IOException {
TomlMapper mapper = new TomlMapper();
return mapper.readValue(new File(filePath), AppConfig.class);
}
}
import java.io.IOException;
public class Main {
public static void main(String[] args) {
String filePath = "path/to/app.toml";
try {
AppConfig config = AppConfig.fromTomlFile(filePath);
System.out.println("Title: " + config.getTitle());
System.out.println("Version: " + config.getVersion());
System.out.println("Debug Mode: " + config.isDebug());
} catch (IOException e) {
e.printStackTrace();
}
}
}