JDK-8297160 : Release Note: The new method Path::getExtension returns the file’s extension
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 20
  • Priority: P4
  • Status: Resolved
  • Resolution: Delivered
  • OS: generic
  • CPU: generic
  • Submitted: 2022-11-16
  • Updated: 2022-11-17
  • Resolved: 2022-11-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 20
20Resolved
Description
Support for obtaining the file extension of a file path's name is added via a new default method `java.nio.file.Path::getExtension`. Some examples:

| File Name String | Extension |
|------------------|-----------|
| "foo.tar.gz"     | "gz"      |
| "foo.bar"        | "bar"     |
| "foo."           | ""        |
| "foo"            | `null`    |
| ".bar"           | `null`    |