Copying a directory in Scala

Using Files.walk from Java 8

Posted by Boris Stumm on Saturday, 1 July 2017

I dont know how often I already searched for some easy directory-copy method in Scala/Java. This time, I stumbled over a Slashdot Article that brought me to a nice Scala-2.12 solution:

import java.nio.file.Files._
import java.nio.file.Path

def copyDir(src: Path, dest: Path): Unit =
  walk(src) forEach (f ⇒ copy(f, dest resolve (src relativize f)))