@@ -614,10 +614,18 @@ private static String changeFirstCharacterCase(String str, boolean capitalize) {
614614 }
615615
616616 /**
617- * Extract the filename from the given Java resource path,
618- * for example, {@code "mypath/myfile.txt" → "myfile.txt"}.
617+ * Extract the filename from the given Java resource path.
618+ * <p>Examples:
619+ * <ul>
620+ * <li>{@code "my/path/myfile.txt"} → {@code "myfile.txt"}
621+ * <li>{@code "myfolder"} → {@code "myfolder"}
622+ * <li>{@code "myfile.txt"} → {@code "myfile.txt"}
623+ * <li>{@code ""} → {@code ""}
624+ * <li>{@code null} → {@code null}
625+ * </ul>
619626 * @param path the file path (may be {@code null})
620- * @return the extracted filename, or {@code null} if none
627+ * @return the extracted filename, the original path if it does not contain a
628+ * forward slash ({@code "/"}), or {@code null} if the supplied path is {@code null}
621629 */
622630 @ Contract ("null -> null; !null -> !null" )
623631 public static @ Nullable String getFilename (@ Nullable String path ) {
@@ -630,10 +638,20 @@ private static String changeFirstCharacterCase(String str, boolean capitalize) {
630638 }
631639
632640 /**
633- * Extract the filename extension from the given Java resource path,
634- * for example, "mypath/myfile.txt" → "txt".
641+ * Extract the filename extension from the given Java resource path.
642+ * <p>Examples:
643+ * <ul>
644+ * <li>{@code "my/path/myfile.txt"} → {@code "txt"}
645+ * <li>{@code "myfile.txt"} → {@code "txt"}
646+ * <li>{@code "my/path/myfile."} → {@code ""}
647+ * <li>{@code "myfile"} → {@code null}
648+ * <li>{@code ""} → {@code null}
649+ * <li>{@code null} → {@code null}
650+ * </ul>
635651 * @param path the file path (may be {@code null})
636- * @return the extracted filename extension, or {@code null} if none
652+ * @return the extracted filename extension (potentially an empty string), or
653+ * {@code null} if the provided path is {@code null} or does not contain a dot
654+ * ({@code "."})
637655 */
638656 public static @ Nullable String getFilenameExtension (@ Nullable String path ) {
639657 if (path == null ) {
0 commit comments