List of utility methods to do FileChannel Copy
void | copyFile(String inName, String otName) fast file copy utility function File inFile = null; File otFile = null; try { inFile = new File(inName); otFile = new File(otName); } catch (Exception e) { e.printStackTrace(); if (inFile == null || otFile == null) return; FileChannel sourceChannel = new FileInputStream(inFile).getChannel(); FileChannel destinationChannel = new FileOutputStream(otFile).getChannel(); sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel); sourceChannel.close(); destinationChannel.close(); |
void | copyFile(String input, String output) copies a file from input to output BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(input))); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(output))); String line = null; while ((line = in.readLine()) != null) { out.write(line); out.newLine(); in.close(); ... |
void | copyFile(String origPath, String destPath) Convenience function to copy a file. FileInputStream fis = null; FileOutputStream fos = null; try { fis = new FileInputStream(origPath); fos = new FileOutputStream(destPath); final FileChannel in = fis.getChannel(); final FileChannel out = fos.getChannel(); in.transferTo(0, in.size(), out); ... |
void | copyFile(String source, String destination) copy File File sourceFile = new File(source); File destinationFile = new File(destination); copyFile(sourceFile, destinationFile); |
void | copyFile(String source, String destination) copy File copyFile(new File(source), new File(destination)); |
void | copyFile(String source, String destination) This copies the given file to the given location (both names must be valid). copyFile(new File(source), new File(destination)); |
void | copyFile(String source, String target) copy File copyFile(new File(source), new File(target)); |
File | copyFile(String source, String target) Copies source file to target. FileChannel inputChannel = null; FileChannel outputChannel = null; try { inputChannel = new FileInputStream(source).getChannel(); outputChannel = new FileOutputStream(target).getChannel(); outputChannel.transferFrom(inputChannel, 0, inputChannel.size()); } finally { if (inputChannel != null) { ... |
boolean | copyFile(String sourceFile, String destFile) Copies a file java.io.File source = new java.io.File(sourceFile); java.io.File dest = new java.io.File(destFile); try { copyFile(source, dest); return true; } catch (IOException e) { e.printStackTrace(); return false; ... |
void | copyFile(String sourceFilename, String destFilename) copy File File sourceFile = new File(sourceFilename); File destFile = new File(destFilename); if (!sourceFile.exists()) { System.out.println("ERROR: Source file " + sourceFilename + " does not exist!"); return; try { if (!destFile.exists()) { ... |