Skip to content

Instantly share code, notes, and snippets.

@marcospereira
Created September 12, 2010 06:14
Show Gist options
  • Save marcospereira/575894 to your computer and use it in GitHub Desktop.
Save marcospereira/575894 to your computer and use it in GitHub Desktop.
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