-
-
Save alonsoir/353cc406b6480256ef6f90c081c9e546 to your computer and use it in GitHub Desktop.
Parsing java properties files with Scala
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 scala.io.Source.fromFile | |
def parseProperties(filename: String): Map[String,String] = { | |
val lines = fromFile(filename).getLines.toSeq | |
val cleanLines = lines.map(_.trim).filter(!_.startsWith("#")).filter(_.contains("=")) | |
cleanLines.map(line => { val Array(a,b) = line.split("=",2); (a.trim, b.trim)}).toMap | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment