Overview | Methods | This Package | All Packages
Changes the extension of a file path.
Syntax
public static String changeExtension( String path, String extension )
Parameters
path
The path for which to change the file extension.
extension
The new file extension (with a leading period) or null to remove the extension.
Return Value
Returns the path with the new file extension.
Remarks
This method returns a file path with the same root, directory, and base name parts as the path parameter, but the file extension changes to the specified extension. If the path parameter is null, the function returns null. If the path parameter does not contain a file extension, a new one is appended to the path. If the extension parameter is null, any existing extension is removed from the path parameter.
See Also getExtension, hasExtension