Skip to content

Instantly share code, notes, and snippets.

@ytRino
Created January 23, 2013 04:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ytRino/4601859 to your computer and use it in GitHub Desktop.
Save ytRino/4601859 to your computer and use it in GitHub Desktop.
public static long copyFileStream(FileInputStream is, FileOutputStream os)
throws IOException {
FileChannel srcChannel = null;
FileChannel destChannel = null;
try {
srcChannel = is.getChannel();
destChannel = os.getChannel();
return srcChannel.transferTo(0, srcChannel.size(), destChannel);
} finally {
if (srcChannel != null) srcChannel.close();
if (destChannel != null) destChannel.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment