Returns the extension of the filename including the leading dot, as a string. If the filename has no extension, returns an empty string.
Note that if the filename starts with a dot (e.g. .gitignore),
that dot is considered part of the stem. So .gitignore has
extension '' and .gitignore.bak has extension .bak
Returns the stem of the filename, i.e. the part before the extension. If the filename has no extension, returns the entire filename
Note that if the filename starts with a dot (e.g. .gitignore),
that dot is considered part of the stem. So .gitignore and
.gitignore.bak both have stem .gitignore
Returns true if this filename equals the other filename or filename string
Replace the filename extension, keeping the stem the same. The passed string can include or omit the leading dot; if omitted, it will be added.
New extension, e.g. json or .json
A new instance with the filename extension replaced.
Returns the filename as string.
Represents a filename (without any path components), and provides methods to query and manipulate it.
The class is immutable; all methods that modify the filename return a new instance.
The constructor ensures that the filename does not contain any directory separators. If it does, an error is thrown.
Example