Skip to content

Instantly share code, notes, and snippets.

@jponge
Created May 6, 2016 10:04
Show Gist options
  • Save jponge/4c0dfb721d52c4970bad12af6d960025 to your computer and use it in GitHub Desktop.
Save jponge/4c0dfb721d52c4970bad12af6d960025 to your computer and use it in GitHub Desktop.
server {
name = "Master"
ip = "192.168.0.10"
files = [
"/var/run/db/1",
"/var/run/db/2",
"/var/run/db/3",
]
}
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
public class Main {
public static void main(String[] args) {
Config defaults = ConfigFactory.load("defaults");
Config myconfig = ConfigFactory.load("myconfig").withFallback(defaults);
Config other = ConfigFactory.load("other").withFallback(myconfig);
System.out.println(
myconfig.getString("server.name"));
System.out.println(
myconfig.getString("server.ip"));
System.out.println(
myconfig.getStringList("server.files"));
System.out.println(
myconfig.getString("server.grappa"));
System.out.println(
other.getString("foo.bar.baz"));
System.out.println(
other.getString("server.name"));
}
}
server {
ip = "192.168.0.30"
grappa = "Grappa is great!"
}
{
"foo": {
"bar": {
"baz": "Foo / Bar / Baz"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment