Skip to content
paradigmatic edited this page Dec 8, 2011 · 4 revisions

Files and Sources

Loading

A configuration can be loaded from a file, by providing the filename as a string:

val config1 = Configuration.load("config1.conf")

or from scala.io.Source:

val config2 = Configuration.load( 
	Source fromURL "http://www.example.com/config/default"
)

The load methods take a second optional parameter of type ImportFormat. By default the BlockFormat is used, see Formats for a list of all currently available formats.

Loading from classpath

A configuration can be directly loaded from the classpath as a resource:

val config3 = Configuration.loadResource("/config3.conf")

The loadResource methods take a second optional parameter of type ImportFormat. By default the BlockFormat is used, see Formats for a list of all currently available formats.

Saving

A configuration can also be saved to a file, by providing the filename:

val config = Configuration.load( "before.conf" )
config.set("name","Gina").save( "after.conf" )

The save method take a second optional parameter of type ExportFormat. By default the BlockFormat is used, see Formats for a list of all currently available formats.

Clone this wiki locally