/** * Copies a file to a new location preserving the file date. This method copies the contents of the specified source file to the specified destination * file. The directory holding the destination file is created if it does not exist. If the destination file exists, then this method will overwrite it. * * @param srcFile an existing file to copy, must not be <code>null</code> * @param destFile the new file, must not be <code>null</code> * @throws Fabric3Exception if an IO error occurs during copying */ public static void copyFile(File srcFile, File destFile) throws Fabric3Exception { copyFile(srcFile, destFile, true); }
public void archive(File file, File archiveDirectory) throws IOException { File destFile = new File(archiveDirectory, file.getName()); FileHelper.copyFile(file, destFile); file.delete(); } }
public void error(File file, File errorDirectory, Exception e) throws IOException { FileHelper.copyFile(file, new File(errorDirectory, file.getName())); file.delete(); }
/** * Copies a file to a directory optionally preserving the file date. This method copies the contents of the specified source file to a file of the same * name in the specified destination directory. The destination directory is created if it does not exist. If the destination file exists, then this method * will overwrite it. * * @param srcFile an existing file to copy, must not be <code>null</code> * @param destDir the directory to place the copy in, must not be <code>null</code> * @param preserveFileDate true if the file date of the copy should be the same as the original * @throws Fabric3Exception if an IO error occurs during copying * @since Commons IO 1.3 */ public static void copyFileToDirectory(File srcFile, File destDir, boolean preserveFileDate) throws Fabric3Exception { if (destDir == null) { throw new NullPointerException("Destination must not be null"); } if (!(destDir.exists() && destDir.isDirectory())) { throw new IllegalArgumentException("Destination '" + destDir + "' is not a directory"); } copyFile(srcFile, new File(destDir, srcFile.getName()), preserveFileDate); }
@SuppressWarnings("ResultOfMethodCallIgnored") private void roll() throws IOException { if (strategy.checkRoll(file)) { stream.close(); File backup = strategy.getBackup(file); FileHelper.copyFile(file, backup); file.delete(); initializeChannel(); } }
@SuppressWarnings("ResultOfMethodCallIgnored") private void roll() throws IOException { if (strategy.checkRoll(file)) { stream.close(); File backup = strategy.getBackup(file); FileHelper.copyFile(file, backup); file.delete(); initializeChannel(); } }