List of utility methods to do FileChannel Copy
void | copyFileUsingChannel(File source, File dest) copy File Using Channel FileInputStream sourceStream = new FileInputStream(source); FileChannel sourceChannel = sourceStream.getChannel(); FileOutputStream outputStream = new FileOutputStream(dest); outputStream.getChannel().transferFrom(sourceChannel, 0, sourceChannel.size()); |
void | copyFileUsingFileChannels(File source, File dest) copy File Using File Channels FileChannel inputChannel = null; FileChannel outputChannel = null; try { inputChannel = new FileInputStream(source).getChannel(); outputChannel = new FileOutputStream(dest).getChannel(); outputChannel.transferFrom(inputChannel, 0, inputChannel.size()); } finally { inputChannel.close(); ... |
void | copyFileUsingFileChannels(File source, File dest) Copy a file FileInputStream inputStream = null; FileOutputStream outputStream = null; FileChannel inputChannel = null; FileChannel outputChannel = null; try { inputStream = new FileInputStream(source); outputStream = new FileOutputStream(dest); if (inputStream != null) ... |
void | copyFileUsingFileChannels(File source, File dest) copy File Using File Channels FileChannel inputChannel = null; FileChannel outputChannel = null; try { inputChannel = new FileInputStream(source).getChannel(); outputChannel = new FileOutputStream(dest).getChannel(); outputChannel.transferFrom(inputChannel, 0, inputChannel.size()); } catch (Exception e) { e.printStackTrace(); ... |
void | copyFolder(File fin, File fout) copy Folder fout.mkdirs(); String[] children = fin.list(); if (children == null) { } else { for (int p = 0; p < children.length; p++) { File f = new File(fin + "/" + children[p]); File f1 = new File(fout + "/" + children[p]); if (f.isDirectory()) ... |
void | copyFromZip(ZipFile zipFile, String locationInBundle, File destination) copy From Zip Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry zipEntry = entries.nextElement(); if (zipEntry.getName().startsWith(locationInBundle)) { String path = zipEntry.getName().substring(locationInBundle.length()); File file = new File(destination, path); if (!zipEntry.isDirectory()) { createFileFromZipFile(file, zipFile, zipEntry); ... |
void | copyInternal(FileInputStream in, FileOutputStream out) copy Internal FileChannel src = in.getChannel(); FileChannel dest = out.getChannel(); src.transferTo(0, src.size(), dest); |
long | copyLarge(FileInputStream in, FileOutputStream out) Copies bytes from a large (over 2GB) FileInputStream to a FileOutputStream .
final FileChannel inc = in.getChannel(); return inc.transferTo(0L, inc.size(), out.getChannel()); |
void | copyNio(final File source_file, final File destination_file) copy Nio if (!source_file.exists()) { return; final File parTo = destination_file.getParentFile(); if (!parTo.exists()) { parTo.mkdirs(); if (!destination_file.exists()) { ... |
void | copyRec(File src, File dst) Copies a directory or a file from source to destination. if (src == null || dst == null) return; if (dst.isFile()) return; if (src.isFile()) { copyFileToDir(src, dst); } else { String name = src.getName(); ... |