Alex Rivera | Logout

Scala script to copy files

Asked 2010-02-08T22:02:31.960
27

I want to copy file a.txt to newDir/ from within a scala script. In java this would be done by creating 2 file streams for the 2 files, reading into buffer from a.txt and writing it to the FileOutputStream of the new file. Is there a better way to achieve this in scala? May be something in scala.tools.nsc.io._. I searched around but could not find much.

Edit
Report

1 Answer

37

Why not use Apache Commons IO and FileUtils.copyFile() in particular ? Note that FileUtils has a large number of methods to copy files/directories etc.

answered 2010-02-08T22:04:43.330

Your Answer