MotaF
MotaF

Reputation: 625

Scala io.source fromFile

I have this two lines(among the all others)

import scala.io.Source

val source = Source.fromFile(filename)

As I understand this is a way to read file content.I have read http://www.scala-lang.org/api/2.12.x/scala/io/Source.html#iter:Iterator[Char]

I still do not get it what does Source.from File represent,one of Type Members,or something else?

Upvotes: 1

Views: 8741

Answers (1)

rogue-one
rogue-one

Reputation: 11587

from the Scala API stated here fromFile is a method defined on the Source companion object. This is a curried method with the first param list taking a single String representing the path of the file to be read and the second curried parameter list takes a single implicit codec argument of type scala.io.Codec. And this function returns a BufferedSource object

Upvotes: 2

Related Questions