Created
September 2, 2013 08:39
-
-
Save lhohan/6410604 to your computer and use it in GitHub Desktop.
File copy using Java7 & Scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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