[ 
https://issues.apache.org/jira/browse/GROOVY-10942?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17690849#comment-17690849
 ] 

ASF GitHub Bot commented on GROOVY-10942:
-----------------------------------------

paulk-asert commented on code in PR #1859:
URL: https://github.com/apache/groovy/pull/1859#discussion_r1111190501


##########
subprojects/groovy-nio/src/main/java/org/apache/groovy/nio/extensions/NioExtensions.java:
##########
@@ -101,6 +101,36 @@ public static long size(Path self) throws IOException {
         return Files.size(self);
     }
 
+    /**
+     * Provide the extension of this path.
+     *
+     * @param self a path object
+     * @return the extension of this path (not including the dot), or an empty 
string if it doesn't have one.
+     * @since 5.0.0
+     */
+    public static String getExtension(Path self) {
+        final Path fileName = self.getFileName();
+        final String name = fileName == null ? "" : fileName.toString();

Review Comment:
   You want `Path.getName()`, with shorthand `Path.name` as a shorthand for 
`Path.getFileName()`/`Path.fileName`?
   That could work but there is the existing `getName(int index)` method which 
might confuse some folks.





> Add `extension` & `nameWithoutExtension` extension methods
> ----------------------------------------------------------
>
>                 Key: GROOVY-10942
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10942
>             Project: Groovy
>          Issue Type: New Feature
>            Reporter: Zongle Wang
>            Priority: Major
>
> Ref:
> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.io.path/java.nio.file.-path/extension.html
> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.io.path/java.nio.file.-path/name-without-extension.html



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to