Skip to content

Instantly share code, notes, and snippets.

@rokon12
Last active March 23, 2017 19:18
Show Gist options
  • Save rokon12/fdc28a812880bcccb06abaa7ec27cc77 to your computer and use it in GitHub Desktop.
Save rokon12/fdc28a812880bcccb06abaa7ec27cc77 to your computer and use it in GitHub Desktop.
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