List of utility methods to do FileChannel Copy
void | copyFile(File sourceFile, File targetFile) copy File if (!targetFile.exists()) { targetFile.createNewFile(); FileChannel sourceStream = null; FileChannel targetStream = null; try { sourceStream = new FileInputStream(sourceFile).getChannel(); targetStream = new FileOutputStream(targetFile).getChannel(); ... |
void | copyFile(File sourceFile, File targetFile) copy File FileInputStream source; FileOutputStream destination; try { source = new FileInputStream(sourceFile); destination = new FileOutputStream(targetFile); FileChannel sourceFileChannel = source.getChannel(); FileChannel destinationFileChannel = destination.getChannel(); long size = sourceFileChannel.size(); ... |
void | copyFile(File sourceFile, File targetFile) copy File if (targetFile.equals(sourceFile)) return; FileInputStream sourceInputStream = null; FileOutputStream targetOutputStream = null; try { sourceInputStream = new FileInputStream(sourceFile); FileChannel sourceChannel = sourceInputStream.getChannel(); targetOutputStream = new FileOutputStream(targetFile); ... |
boolean | copyFile(File src, File dest) copy File boolean result = false; try { FileInputStream fis = new FileInputStream(src); FileChannel sourcefc = fis.getChannel(); FileOutputStream fos = new FileOutputStream(dest); FileChannel targetfc = fos.getChannel(); if (sourcefc.transferTo(0, sourcefc.size(), targetfc) == sourcefc.size()) { result = true; ... |
void | copyFile(File src, File dest) Copies a file to a new location preserving the file date. if (src == null) throw new NullPointerException("Source must not be null"); if (dest == null) throw new NullPointerException("Destination must not be null"); if (!src.exists()) throw new FileNotFoundException("Source '" + src + "' does not exist"); if (!src.isFile()) throw new IOException("Source '" + src + "' is not a file"); ... |
void | copyFile(File src, File dest) copy File FileChannel inChannel = new FileInputStream(src).getChannel(); FileChannel outChannel = new FileOutputStream(dest).getChannel(); int maxCount = (64 * 1024 * 1024) - (32 * 1024); long size = inChannel.size(); long position = 0; while (position < size) { position += inChannel.transferTo(position, maxCount, outChannel); if (inChannel != null) inChannel.close(); if (outChannel != null) outChannel.close(); dest.setLastModified(src.lastModified()); |
void | copyFile(File src, File dest) Copies all file to another file. dest.createNewFile(); try (FileInputStream in = new FileInputStream(src); FileOutputStream out = new FileOutputStream(dest)) { FileChannel srcChannel = in.getChannel(); FileChannel destChannel = out.getChannel(); destChannel.transferFrom(srcChannel, 0, srcChannel.size()); |
void | copyFile(File src, File destination) copy File FileChannel in = null; FileChannel out = null; try { in = new FileInputStream(src).getChannel(); out = new FileOutputStream(destination).getChannel(); in.transferTo(0, in.size(), out); } finally { try { ... |
void | copyFile(File src, File destination) copy File try { if (!destination.exists()) { destination.createNewFile(); FileChannel in = new FileInputStream(src).getChannel(); FileChannel out = new FileOutputStream(destination).getChannel(); out.transferFrom(in, 0, in.size()); } catch (IOException e) { ... |
void | copyFile(File src, File dst) copy File FileChannel src_channel = new FileInputStream(src).getChannel(); FileChannel dst_channel = new FileOutputStream(dst).getChannel(); src_channel.transferTo(0, Long.MAX_VALUE, dst_channel); src_channel.close(); dst_channel.close(); |