Created
September 12, 2010 06:14
-
-
Save marcospereira/575894 to your computer and use it in GitHub Desktop.
This file contains 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 groovy.util.ConfigObject; | |
import groovy.util.ConfigSlurper; | |
import java.io.File; | |
import java.net.MalformedURLException; | |
import java.net.URI; | |
import java.net.URL; | |
import java.util.Map; | |
public class LoadConfiguration { | |
public static void main(String[] args) throws Exception { | |
ConfigSlurper sluper = new ConfigSlurper(); | |
ConfigObject configObject = sluper.parse(url("application.conf")); | |
Map properties = configObject.flatten(); | |
System.out.println(properties.get("application.name")); | |
} | |
private static URL url(String path) throws MalformedURLException { | |
URI uri = new File(path).toURI(); | |
URL url = uri.toURL(); | |
return url; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment