- getFilePathContent(): This method takes full path of file and reads its content into string
- getResourceContent(): THis method takes relative path of a file already available on classpath and converts it into String
This file contains 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 | |
object ScalaFileReader { | |
def getFilePathContent(configPath: String): String = { | |
scala.io.Source.fromFile(configPath).getLines().mkString("\n") | |
} | |
def getResourceContent(resourcePath: String): String = { | |
Source.fromURL(getClass.getResource(resourcePath)).getLines().mkString("\n") | |
} | |
} |