List of utility methods to do File Copy
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 pSourceFile, File pTargetFile) copy if (!pSourceFile.getCanonicalPath().equals( pTargetFile.getCanonicalPath())) { pTargetFile.getParentFile().mkdirs(); FileInputStream lFIS = new FileInputStream(pSourceFile); FileOutputStream lFOS = new FileOutputStream( pTargetFile.getCanonicalPath()); copy(lFIS, lFOS); lFOS.close(); ... |
void | copy(File source, File target, boolean append) Copies source to target. Check.arg().validFile(source); Check.arg().notNull(target); if (source.getCanonicalPath().equals(target.getCanonicalPath())) throw new IllegalArgumentException( "source and target resolve to the same path = " + source.getCanonicalPath()); InputStream in = null; OutputStream out = null; ... |
void | copy(File sourceFile, File destinationFile) copy FileReader reader = null; FileWriter writer = null; try { reader = new FileReader(sourceFile); writer = new FileWriter(destinationFile); int data = reader.read(); while (data != -1) { writer.write(data); ... |
void | copy(File sourceFile, File targetFile) Copy the source file to the target file. copy(sourceFile, targetFile, false); |
boolean | copy(File sourceFile, File targetFile, boolean overwrite) Copy the source file to the target file while optionally permitting an overwrite to occur in case the target file already exists. boolean overwriteOccurred = false; if (targetFile.exists()) { if (!overwrite) { throw new FileAlreadyExistsException("Target file " + targetFile + " already exists"); } else { overwriteOccurred = true; FileInputStream fis = new FileInputStream(sourceFile); FileOutputStream fos = new FileOutputStream(targetFile); fis.getChannel().transferTo(0, sourceFile.length(), fos.getChannel()); fis.close(); fos.flush(); fos.close(); return overwriteOccurred; |
void | copy(File sourceFile, String destinction) copy if (!sourceFile.exists()) return; File dest_f = new File(destinction); if (!dest_f.exists()) dest_f.mkdirs(); if (sourceFile.isDirectory()) { java.io.File[] files = sourceFile.listFiles(); for (int i = 0; files != null && i < files.length; i++) { ... |
void | copy(File src, File dest) copy if (src.isDirectory()) { if (!dest.exists()) { dest.mkdir(); String files[] = src.list(); for (String file : files) { File srcFile = new File(src, file); File destFile = new File(dest, file); ... |
boolean | copy(String input, String output) This class copies an input file to output file int BUFSIZE = 65536; FileInputStream fis = new FileInputStream(input); FileOutputStream fos = new FileOutputStream(output); try { int s; byte[] buf = new byte[BUFSIZE]; while ((s = fis.read(buf)) > -1) { fos.write(buf, 0, s); ... |
void | copy(String pSourceFile, String pTargetFile) copy copy(new File(pSourceFile), new File(pTargetFile)); |