| author | Tomas Zeman <tzeman@volny.cz> |
| Thu, 13 Dec 2018 14:21:10 +0100 | |
| changeset 18 | 8cfd67425811 |
| parent 16 | 4556852613a9 |
| child 23 | afcfbdeb3b88 |
| permissions | -rw-r--r-- |
package sqwl import java.nio.file.Path import scala.io.Source import scala.util.{Failure, Success, Try} package object cms { def readSourceFull(src: Source): Try[String] = { try { Success(src.getLines.mkString) } catch { case t: Throwable => Failure(t) } finally { src.close() } } def readFile(f: Path, enc: String = "UTF-8"): Try[String] = readSourceFull(Source.fromFile(f.toFile, enc)) def readFile(f: String): String = readSourceFull(Source.fromFile(f, "UTF-8")) getOrElse "" }