bio.ferlab.datalake.spark3.utils.ResourceLoader.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of datalake-spark3_2.12 Show documentation
Show all versions of datalake-spark3_2.12 Show documentation
Library built on top of Apache Spark to speed-up data lakes development..
package bio.ferlab.datalake.spark3.utils
import scala.io.Source
import scala.util.{Failure, Success, Try, Using}
object ResourceLoader {
def loadResource(path: String): Option[String] = {
Using(getClass.getClassLoader.getResourceAsStream(path)) { is =>
if (is == null) None else Some(Source.fromInputStream(is).mkString)
}.toOption.flatten
}
}