Last active
March 23, 2017 19:18
-
-
Save rokon12/fdc28a812880bcccb06abaa7ec27cc77 to your computer and use it in GitHub Desktop.
This file contains 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
import java.io.IOException; | |
import java.nio.file.Files; | |
import java.nio.file.Path; | |
import java.nio.file.Paths; | |
public class Copier { | |
public void copy(String from, String to) { | |
System.out.println("copying file from: " + from + " -> to: " + to); | |
Path src = Paths.get(from); | |
if (!src.toFile().exists()) { | |
System.out.println("source file doesn't exist"); | |
return; | |
} | |
Path dest = Paths.get(to); | |
try { | |
Files.copy(src, dest); | |
} catch (IOException e) { | |
System.err.println("Couldn't copy file : " + e.getMessage() + " " + e.getCause().getMessage()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment