/** * Deep copies source to target and creates the target if necessary. * <p> * The source can be a directory or a file and the target can be a directory or file. * <p> * If the source is a directory, it expects that the target is a directory (or that it doesn't exist) * and nests the copied source under the target directory. * * @param source the source * @param target the destination * @throws IllegalArgumentException if the source was not found or the source is a directory and the target is a file * @throws HazelcastException if there was any exception while creating directories or copying */ public static void copy(File source, File target) { if (!source.exists()) { throw new IllegalArgumentException("Source does not exist"); } if (source.isDirectory()) { copyDirectory(source, target); } else { copyFile(source, target, -1); } }
/** * Deep copies source to target and creates the target if necessary. * <p> * The source can be a directory or a file and the target can be a directory or file. * <p> * If the source is a directory, it expects that the target is a directory (or that it doesn't exist) * and nests the copied source under the target directory. * * @param source the source * @param target the destination * @throws IllegalArgumentException if the source was not found or the source is a directory and the target is a file * @throws HazelcastException if there was any exception while creating directories or copying */ public static void copy(File source, File target) { if (!source.exists()) { throw new IllegalArgumentException("Source does not exist"); } if (source.isDirectory()) { copyDirectory(source, target); } else { copyFile(source, target, -1); } }