Flat 10% & upto 50% off + Free additional Courses. Hurry up!

Scala File Input and Output


File operations mostly includes reading data from file or writing data into files.


Writing Data form File


import java.io._

object Intellipaat {

def main(args: Array[String]) {

val writer = new PrintWriter(new File("intellipaat.txt" ))

writer.write("Hello Intellipaat")




When we compile and execute this program then it write Hello Intellipaat in intellipaat.txt file.


Reading Data from File


import scala.io.Source

object Intellipaat {

def main(args: Array[String]) {

println("Data in File is:" )

Source.fromFile("intellipaat.txt" ).foreach{





Compile and execute the above program:

scalac Intellipaat.scala

scala Intellipaat


Data in file is: Hello Intellipaat

This blog will help you get a better understanding of Significance Of Scala!

"0 Responses on Scala File Input and Output"

Training in Cities

Bangalore, Hyderabad, Chennai, Delhi, Kolkata, UK, London, Chicago, San Francisco, Dallas, Washington, New York, Orlando, Boston

100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.


Sales Offer

  • To avail this offer, enroll before 28th October 2016.
  • This offer cannot be combined with any other offer.
  • This offer is valid on selected courses only.
  • Please use coupon codes mentioned below to avail the offer
DW offer

Sign Up or Login to view the Free Scala File Input and Output.