List of utility methods to do File Copy nio
boolean | copy(File inFile, File outFile) This method copies one file to another location if (!inFile.exists()) { return false; FileChannel in = null; FileChannel out = null; try { in = new FileInputStream(inFile).getChannel(); out = new FileOutputStream(outFile).getChannel(); ... |
void | copy(File input, File output) copy FileInputStream fis = new FileInputStream(input); FileOutputStream fos = new FileOutputStream(output); try { FileChannel ic = fis.getChannel(); FileChannel oc = fos.getChannel(); try { oc.transferFrom(ic, 0, ic.size()); } finally { ... |
void | copy(File inputFile, OutputStream out) copy copy(inputFile, out, false); |
void | copy(File source, File dest) copy 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 | copy(File source, File dest) copy Files.copy(source.toPath(), dest.toPath()); if (source.isDirectory()) { for (String s : source.list()) { copy(new File(source, s), new File(dest, s)); |
void | copy(File source, File dest) Copy a file. Files.copy(source.toPath(), dest.toPath()); |
void | copy(File source, File dest) copy FileChannel in = null, out = null; try { in = new FileInputStream(source).getChannel(); out = new FileOutputStream(dest).getChannel(); long size = in.size(); MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, 0, size); out.write(buf); } finally { ... |
void | copy(File source, File dest) Copy a file from the source file to the destination file. if (source.isDirectory()) { dest.mkdir(); for (File child : listFiles(source)) { copy(child, new File(dest, child.getName())); } else { if (source.exists()) { long lm = source.lastModified(); ... |
void | copy(File source, File dest, boolean preserveTime) Copies file source to location dest .
FileChannel in = null, out = null; try { dest.getParentFile().mkdirs(); in = new FileInputStream(source).getChannel(); out = new FileOutputStream(dest).getChannel(); long size = in.size(); MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, 0, size); out.write(buf); ... |
void | copy(File source, File destination) copy if (source.isDirectory()) { copyDirectory(source, destination); } else { copyFile(source, destination); |