Friday, March 11, 2016

reading file in Scala

Files can be read in Scala using the below code.

Here as I have defined a dedicated packages for all the examples presented here i.e example which is defined in first line. We need to import package for the io operation. We defined a class/object Main in which we defined a main method. We have defined a variable filename in which we have decalred our file name with the path and read its content using the for loop over the file lines.

No comments:

Post a Comment