Created
May 6, 2016 10:04
-
-
Save jponge/4c0dfb721d52c4970bad12af6d960025 to your computer and use it in GitHub Desktop.
Sample usage of https://github.com/typesafehub/config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
name = "Master" | |
ip = "192.168.0.10" | |
files = [ | |
"/var/run/db/1", | |
"/var/run/db/2", | |
"/var/run/db/3", | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
ip = "192.168.0.30" | |
grappa = "Grappa is great!" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"foo": { | |
"bar": { | |
"baz": "Foo / Bar / Baz" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment