List of utility methods to do FileInputStream Copy
File | copyFileContents(File fromFile, File destination, boolean useTempFilenames) Copy a file into destination destination . FileInputStream from = null; FileOutputStream to = null; File toFile = null; if (useTempFilenames) { toFile = File.createTempFile(TMP_DIRECTORY_PREFIX, "", destination); } else { toFile = new File(destination.getAbsolutePath() + File.separatorChar + fromFile.getName()); try { from = new FileInputStream(fromFile); to = new FileOutputStream(toFile); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = from.read(buffer)) != -1) { to.write(buffer, 0, bytesRead); } finally { if (from != null) { try { from.close(); } catch (IOException e) { if (to != null) { try { to.close(); } catch (IOException e) { return toFile; |
void | copyFileFolder(final File source, final File dest, final boolean override) copy File Folder if (dest.exists()) { if (!override) { return; } else { deleteFileFolder(dest); if (source.isDirectory()) { ... |
void | copyFileFromFileToFile(File fromFile, File toFile) copy File From File To File FileInputStream in = new FileInputStream(fromFile); FileOutputStream out = new FileOutputStream(toFile); copyFile(in, out); in.close(); in = null; out.flush(); out.close(); out = null; ... |
void | copyFileFromTo(String filename, File fromDir, File toDir) copy File From To copyFile(new File(fromDir, filename), new File(toDir, filename)); |
void | copyFileLowLevel(File source, File target) copy File Low Level target.getParentFile().mkdirs(); final InputStream is = new FileInputStream(source); final OutputStream os = new FileOutputStream(target); final byte[] buffer = new byte[65536]; int c; while ((c = is.read(buffer)) != -1) { os.write(buffer, 0, c); os.close(); is.close(); |
void | copyFileR(File srcFile, File destDirectory) copy File R File destFile = new File(destDirectory.getAbsolutePath() + File.separator + srcFile.getName()); if (srcFile.isDirectory()) { destFile.mkdir(); File[] fileList = srcFile.listFiles(); for (int i = 0; i < fileList.length; i++) { File file = fileList[i]; copyFileR(file, destFile); } else { copyFile(srcFile, destFile); |
void | copyFileRecursive(File src, File dest) This function will copy files or directories from one location to another. if (!src.exists()) { throw new IOException("copyFiles: Can not find source: " + src.getAbsolutePath() + "."); } else if (!src.canRead()) { throw new IOException("copyFiles: No right to source: " + src.getAbsolutePath() + "."); if (src.isDirectory()) { if (!dest.exists() && !dest.mkdirs()) { throw new IOException("copyFiles: Could not create direcotry: " + dest.getAbsolutePath() + "."); ... |
File | copyFileToAnotherDirWithRelativePaths(File srcDir, File destDir, File originalFile) copy File To Another Dir With Relative Paths String relativePath = makeRelativePath(srcDir.getAbsolutePath(), originalFile.getAbsolutePath(), ""); File newFile = new File(destDir, relativePath); FileInputStream fis = new FileInputStream(originalFile); FileOutputStream fos = new FileOutputStream(newFile); ByteStreams.copy(fis, fos); fis.close(); fos.close(); return newFile; ... |
void | copyFileToContainer(File pChild, IContainer pContainer) copy File To Container if (pChild.isDirectory()) { internalCopyFolderToContainer(pChild, pContainer); } else { internalCopyFileToContainer(pChild, pContainer); |
void | copyFileToDestDir(String srcFilePath, String destFileDir) copy File To Dest Dir File srcFile = new File(srcFilePath); File destFile = new File(destFileDir + "/" + srcFile.getName()); copyFile(srcFile, destFile); |