@Override public void renameTo(AbstractFile destFile) throws IOException, UnsupportedFileOperationException { file.renameTo(destFile); }
/** * Moves the given source file to the destination one, using either {@link AbstractFile#renameTo(AbstractFile)} or * {@link AbstractFile#moveTo(AbstractFile)} depending on the parameter's value. * * @param sourceFile the source file to move/rename * @param destFile the destination file to move/rename the source file to * @param useRenameTo <code>true</code> to use {@link AbstractFile#renameTo(AbstractFile)}, <code>false</code> to * use {@link AbstractFile#moveTo(AbstractFile)} * @throws IOException in case of an error */ protected void moveTo(AbstractFile sourceFile, AbstractFile destFile, boolean useRenameTo) throws IOException { if(useRenameTo) sourceFile.renameTo(destFile); else sourceFile.moveTo(destFile); }
fileToDelete.renameTo(TRASH_FILES_SUBFOLDER.getChild(trashFileName)); } catch (IOException ex) { try {
fileToDelete.renameTo(TRASH_FILES_SUBFOLDER.getChild(trashFileName)); } catch (IOException ex) { try {
/** * Tests {@link AbstractFile#renameTo(AbstractFile)} when the operation is not supported. * * @throws IOException should not happen */ protected void testRenameToUnsupported() throws IOException { // Assert that #renameTo throws a proper UnsupportedFileOperationException when called UnsupportedFileOperationException e = null; try { tempFile.renameTo(getTemporaryFile()); } catch(UnsupportedFileOperationException ex) { e = ex; } assertUnsupportedFileOperationException(e, FileOperation.RENAME); }
public static void renameCustomTheme(Theme theme, String name) throws IOException { if(theme.getType() != Theme.CUSTOM_THEME) throw new IllegalArgumentException("Cannot rename non-custom themes."); // Makes sure the operation is necessary. if(theme.getName().equals(name)) return; // Computes a legal new name and renames theme. name = getAvailableCustomThemeName(name); getCustomThemesFolder().getChild(theme.getName() + ".xml").renameTo(getCustomThemesFolder().getChild(name + ".xml")); theme.setName(name); if(isCurrentTheme(theme)) setConfigurationTheme(theme); }
renameTo(destFile);
/** * Asserts that a file can be renamed to a filename variation of the same file. * * @throws IOException should not normally happen * @throws NoSuchAlgorithmException should not happen */ @Test public void testRenameToCaseVariation() throws IOException, NoSuchAlgorithmException { // First test with a regular file createFile(tempFile, 1); AbstractFile destFile = tempFile.getParent().getDirectChild(tempFile.getName().toUpperCase()); deleteWhenFinished(destFile); tempFile.renameTo(destFile); assert !destFile.isSymlink(); // Leave me // Repeat the test with a directory destFile.delete(); tempFile.mkdir(); tempFile.renameTo(destFile); assert !destFile.isSymlink(); // Leave me }
file.renameTo(destFile); return true;