Rename the given file to get the given name. @param newName The new name, including extension, excluding directory name. @throws IOException When a problem occurs, or is expected to occur. The error message should be already translated.
(String newName)
| 175 | * message should be already translated. |
| 176 | */ |
| 177 | public void renameTo(String newName) throws IOException { |
| 178 | File newFile = new File(file.getParentFile(), newName); |
| 179 | sketch.checkNewFilename(newFile); |
| 180 | if (!file.exists() || file.renameTo(newFile)) { |
| 181 | renamedTo(newFile); |
| 182 | } else { |
| 183 | String msg = I18n.format(tr("Failed to rename \"{0}\" to \"{1}\""), file.getName(), newName); |
| 184 | throw new IOException(msg); |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * Should be called when this file was renamed and renameTo could not |