code: public static String lastPathComponent(final String str) {
          final String[] segments = str.split("/");
          if (segments != null && segments.length > 0) { return segments[segments.length - 1]; }
          else { return str; }
      }
docs: https://developer.apple.com/reference/foundation/nsstring/1416528-lastpathcomponent