diff --git a/src/java.base/share/classes/java/nio/file/Path.java b/src/java.base/share/classes/java/nio/file/Path.java
index 8a2c233bdf25..07d510c2faee 100644
--- a/src/java.base/share/classes/java/nio/file/Path.java
+++ b/src/java.base/share/classes/java/nio/file/Path.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -249,6 +249,57 @@ public static Path of(URI uri) {
      */
     Path getFileName();
 
+    /**
+     * Returns the file extension of this path's file name as a {@code String}.
+     * The extension is derived from this {@code Path} by obtaining the
+     * {@linkplain #getFileName file name element}, deriving its {@linkplain
+     * #toString string representation}, and then extracting a substring
+     * determined by the position of a period character ('.', U+002E FULL STOP)
+     * within the file name string. If the file name element is {@code null},
+     * or if the file name string does not contain a period character, or if
+     * the only period in the file name string is its first character,  then
+     * the extension is {@linkplain String#isEmpty empty}. Otherwise, the
+     * extension is the substring starting with the last period in the file
+     * name string. If this last period is also the last character in the file
+     * name string, then the extension contains only a single period character.
+     *
+     * @apiNote
+     * Unless no extension is found, in which case an empty string is returned,
+     * the returned extension includes the period separator character. For
+     * example, the extension which would be returned for a path with file name
+     * "photograph.jpg" is ".jpg".
+     *
+     * @implSpec
+     * The default implementation is equivalent for this path to:
+     * <pre>{@code
+     * int lastPeriod = fileName.lastIndexOf('.');
+     * return lastPeriod <= 0 ? return "" : fileName.substring(lastPeriod);
+     * }</pre>
+     *
+     * @return  the non-{@code null} file extension of this path's file name,
+     *          possibly only a single period character, or an empty string if
+     *          no extension is found
+     *
+     * @since 21
+     */
+    default String getExtension() {
+        // empty extension if the file name is null
+        Path fileName = getFileName();
+        if (fileName == null)
+            return "";
+
+        // locate the last dot in the file name string
+        String fileNameString = fileName.toString();
+        int lastDot = fileNameString.lastIndexOf('.');
+
+        // empty  extension if no dot or the last dot is the first character
+        if (lastDot <= 0)
+            return "";
+
+        // the extension is the substring starting at the index of the last dot
+        return fileNameString.substring(lastDot);
+    }
+
     /**
      * Returns the <em>parent path</em>, or {@code null} if this path does not
      * have a parent.
diff --git a/test/jdk/java/nio/file/Path/Extensions.java b/test/jdk/java/nio/file/Path/Extensions.java
new file mode 100644
index 000000000000..4717fb7583f7
--- /dev/null
+++ b/test/jdk/java/nio/file/Path/Extensions.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.nio.file.Path;
+
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/*
+ * @test
+ * @bug 8057113
+ * @summary Verify getExtension method
+ * @run testng Extensions
+ */
+public class Extensions {
+    /**
+     * Returns path name string and expected extension pairs.
+     *
+     * @return {@code {{"pathname", "extension"},...}}
+     */
+    @DataProvider
+    static Object[][] getProvider() {
+        Object[][] pairs = {
+            {"",               ""},
+            {".",              ""},
+            {"..",             "."},
+            {"...",            "."},
+            {"....",           "."},
+            {".....",          "."},
+            {"aa",             ""},
+            {"a.",             "."},
+            {".a",             ""},
+            {"..a",            ".a"},
+            {"...a",           ".a"},
+            {"....a",          ".a"},
+            {".a.b",           ".b"},
+            {"...a.b",         ".b"},
+            {"...a.b.",        "."},
+            {"a..b",           ".b"},
+            {"a..b.c",         ".c"},
+            {"a.b..c",         ".c"},
+            {"a..b.",          "."},
+            {".a..b",          ".b"},
+            {".a..b.c",        ".c"},
+            {".a.b..c",        ".c"},
+            {".a..b.",         "."},
+            {"..a..b",         ".b"},
+            {"..a..b.c",       ".c"},
+            {"..a.b..c",       ".c"},
+            {"..a..b.",        "."},
+            {"..foo",          ".foo"},
+            {"foo.",           "."},
+            {"test.",          "."},
+            {"test..",         "."},
+            {"test...",        "."},
+            {"test.rb",        ".rb"},
+            {"a/b/d/test.rb" , ".rb"},
+            {".a/b/d/test.rb", ".rb"},
+            {"test",           ""},
+            {".profile",       ""},
+            {".profile.sh",    ".sh"},
+            {"foo.tar.gz",     ".gz"},
+            {"foo.bar.",       "."},
+            {"archive.zip",    ".zip"},
+            {"compress.gzip",  ".gzip"},
+            {"waitwhat.&$!#%", ".&$!#%"},
+            {"6.283185307",    ".283185307"}
+        };
+        return pairs;
+    }
+
+    @Test(dataProvider = "getProvider")
+    public static void get(String pathname, String extension) {
+        Assert.assertEquals(Path.of(pathname).getExtension(), extension);
+    }
+}
