Skip to content

Commit

Permalink
API-1888 - Load file from resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas VANDEVELDE committed Sep 9, 2016
1 parent 7645e92 commit 4452e8d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package uk.gov.hmrc.openidconnect.userinfo.services

import scala.io.Source.fromFile
import scala.io.Source

trait CountryService {

Expand All @@ -26,5 +26,13 @@ trait CountryService {
}

object CountryService extends CountryService {
override val countries = fromFile("conf/country.properties").getLines().map(_.split("=")).map(t => (t(0), t(1))).toMap
override val countries = loadCountriesFromFile("/resources/country.properties")

private def loadCountriesFromFile(file: String) = {
val is = getClass.getResourceAsStream(file)
try {
val lines = Source.fromInputStream(is).getLines().toSeq
lines.map(_.split("=")).map(t => (t(0), t(1))).toMap
} finally is.close()
}
}
File renamed without changes.

0 comments on commit 4452e8d

Please sign in to comment.