Read File Content in Scala
In this example, we will show you about how to read file content in scala program language. The example were tested with environment and attached in the post.
Example Code
import java.io.File; import java.io.FileReader; object ReadFile { def main(args: Array[String]) { var file = new File("abc.txt"); var fileReader = new FileReader(file); var data = fileReader.read(); while(data != -1) { print(data.toChar); data = fileReader.read(); } fileReader.close(); } }
Input File
Output
Hello everyone, This is Dinesh Krishnan
More from my site

Hello, folks, I am a founder of idineshkrishnan.com. I love open source technologies, If you find my tutorials are useful, please consider making donations to these charities.
No responses yet