Created
April 8, 2013 17:43
-
-
Save edipofederle/5338816 to your computer and use it in GitHub Desktop.
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
| public static void copyFile(File sourceFile, File destFile) throws IOException { | |
| if (!sourceFile.exists()) { | |
| return; | |
| } | |
| if (!destFile.exists()) { | |
| destFile.createNewFile(); | |
| } | |
| FileChannel source = new FileInputStream(sourceFile).getChannel(); | |
| FileChannel destination = new FileOutputStream(destFile).getChannel(); | |
| if (destination != null && source != null) { | |
| destination.transferFrom(source, 0, source.size()); | |
| } | |
| if (source != null) { | |
| source.close(); | |
| } | |
| if (destination != null) { | |
| destination.close(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment