Skip to content

Instantly share code, notes, and snippets.

@lhohan
Created September 2, 2013 08:39
Show Gist options
  • Save lhohan/6410604 to your computer and use it in GitHub Desktop.
Save lhohan/6410604 to your computer and use it in GitHub Desktop.
File copy using Java7 & Scala
Java 7 is now out and you have another option: java.nio.file.Files.copy. The probably easiest solution (And with Scalas superior import even easier). Provided that from and to are strings as in your question:
import java.nio.file.StandardCopyOption.REPLACE_EXISTING
import java.nio.file.Files.copy
import java.nio.file.Paths.get
implicit def toPath (filename: String) = get(filename)
copy (from, to, REPLACE_EXISTING)
Of course you should start using java.nio.file.Paths instead of strings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment