List of utility methods to do File Copy
void | copy(File from, File to) copy try { File w = new File(to, from.getName()); if (!w.exists()) w.createNewFile(); BufferedOutputStream write = new BufferedOutputStream(new FileOutputStream(w)); BufferedInputStream read = new BufferedInputStream(new FileInputStream(from)); byte[] buffer = new byte[1024]; int l = 0; ... |
void | copyFile(File source, File target) copy File copyFile(source.toPath(), target.toPath()); |
void | copyFile(File src, File dest, Component parentComponent, String message) copy File InputStream in = new FileInputStream(src); OutputStream out = new FileOutputStream(dest); copyFile(in, out, parentComponent, message); out.flush(); out.close(); in.close(); dest.setLastModified(src.lastModified()); |
void | copyFileFromFileSystem(String sourceFileName, File target) copy File From File System try { File in = new File(sourceFileName); FileChannel inChannel = new FileInputStream(in).getChannel(); FileChannel outChannel = new FileOutputStream(target).getChannel(); try { inChannel.transferTo(0, inChannel.size(), outChannel); } catch (IOException e) { throw e; ... |
void | copyFiles(File file, File destPath) Copy files to destPath, can be a folder. if (file.isDirectory()) { File dest = new File(destPath, file.getName()); File[] files = file.listFiles(); for (File subFile : files) { copyFiles(subFile, dest); } else { copyFile(file, destPath); ... |
void | copyFiles(File fromDir, File toDir) Copies all files in fromDir to toDir. String[] names = fromDir.list(); if (names != null) { for (int i = 0; i < names.length; i += 1) { File fromFile = new File(fromDir, names[i]); if (fromFile.isDirectory()) { continue; File toFile = new File(toDir, names[i]); ... |
void | copyFiles(File source, File destination) Copies the contents of one file to another. copyStreams(new FileInputStream(source), new FileOutputStream(destination)); |
void | copyFiles(File sourceFile, File targetDir) Copies an existing structure to a new destination. copyFiles(sourceFile, sourceFile, targetDir); |
void | copyFiles(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()) { if (!dest.mkdirs()) { ... |
void | copyFiles(File src, File dest) Copy files. if (!src.exists()) { throw new IOException("Resource does not exist: " + src.getAbsolutePath()); } else if (!src.canRead()) { throw new IOException("Insufficient privileges to open: " + src.getAbsolutePath()); if (src.isDirectory()) { if (!dest.exists() || !dest.mkdirs()) { throw new IOException("Cannot create: " + dest.getAbsolutePath()); ... |