Class FileRenamer
java.lang.Object
me.pauleff.common.handlers.files.FileRenamer
Renames files while optionally preserving the source file extension.
-
Method Summary
Modifier and TypeMethodDescriptionstatic PathrenamePreservingExtension(Path source, String newFileName) Renames a file, preserving the original extension when the new name does not include one.
-
Method Details
-
renamePreservingExtension
Renames a file, preserving the original extension when the new name does not include one.If the source has an extension and
newFileNamedoes not end with that extension, the extension is appended. An existing file at the target path is replaced.- Parameters:
source- the file to renamenewFileName- the desired file name, with or without an extension- Returns:
- the path of the renamed file
- Throws:
NullPointerException- ifsourceornewFileNameisnullIOException- if the rename fails
-