Skip to content

Instantly share code, notes, and snippets.

@alvindizon
Last active May 12, 2020 08:40
Show Gist options
  • Save alvindizon/2d5ecbe678e572726c47a491c8bfc0fc to your computer and use it in GitHub Desktop.
Save alvindizon/2d5ecbe678e572726c47a491c8bfc0fc to your computer and use it in GitHub Desktop.
copy file in java using NIO
try(FileChannel in = new FileInputStream(src).getChannel();
FileChannel out = new FileOutputStream(dest).getChannel() ) {
in.transferTo(0, in.size(), out);
} catch (IOException e) {
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment