/** * Moves a given source file to a given destination directory. * * @param source * The given source file. * @param destinationDir * The given destination directory. * @return <code>true</code> if the move operation completed successfully, <code>false</code> * otherwise. * @throws IOException * If any I/O exception occurred. */ public static boolean moveFile(File source, File destinationDir) throws IOException { boolean completed = false; File destination = new File(destinationDir, source.getName()); if (destination.exists()) destination.delete(); if (copyFile(source, destination)) { completed = source.delete(); } return completed; }
/** * Restores original files in the 'conf' and 'desc' directories from the back-up copies (with * extension '.$'). * * @return <code>true</code> if the operation completed successfully, <code>false</code> * otherwise. * @throws IOException * if any I/O exception occurred. */ public synchronized boolean undoComponentLocalization() throws IOException { boolean completed = false; int counter = 0; for (int i = 0; i < _localizedFiles.length; i++) { File orgFile = _localizedFiles[i]; String bakFileName = orgFile.getName().concat(BACKUP_FILE_SUFFIX); File bakFile = new File(orgFile.getParent(), bakFileName); if (FileUtil.copyFile(bakFile, orgFile)) { bakFile.delete(); counter++; } else { System.err.println("[LocalInstallationAgent]: " + "failed to undo changes for the file " + orgFile.getAbsolutePath()); } } completed = (counter == _localizedFiles.length); return completed; }
String bakFileName = orgFile.getName().concat(BACKUP_FILE_SUFFIX); File bakFile = new File(orgFile.getParent(), bakFileName); if (FileUtil.copyFile(orgFile, bakFile)) { String bakFileName = orgFile.getName().concat(BACKUP_FILE_SUFFIX); File bakFile = new File(orgFile.getParent(), bakFileName); if (FileUtil.copyFile(orgFile, bakFile)) {
String pearFileName = (new File(pearFileUrl.getFile())).getName(); pearFile = new File(targetDir, pearFileName); if (!FileUtil.copyFile(pearFileUrl, pearFile)) throw new IOException("cannot copy " + pearFileUrl + " to file " + pearFile.getAbsolutePath());