Skip to content

Instantly share code, notes, and snippets.

@ramn
Last active October 11, 2015 18:17
Show Gist options
  • Save ramn/3899914 to your computer and use it in GitHub Desktop.
Save ramn/3899914 to your computer and use it in GitHub Desktop.
Properties files with Scala
import java.util.Properties
val in = getClass.getClassLoader.getResourceAsStream("config_values.properties")
// The Classloader is not always available (sbt test runner), then use the current class instead:
// val in = getClass.getResourceAsStream("config_values.properties")
val props = new Properties()
props.load(in)
in.close
props.getProperty("my.property.name", "default-value")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment