code: public static String getFilenameFromString(String filePath) {
          String newPath = filePath;
  
          int forwardInd = filePath.lastIndexOf("/");
          int backInd = filePath.lastIndexOf("\\");
  
          if (forwardInd > backInd) {
              newPath = filePath.substring(forwardInd + 1);
          } else {
              newPath = filePath.substring(backInd + 1);
          }
  
          // still original if no occurance of "/" or "\"
          return newPath;
      }
docs: Extracts the filename from a path.
  
  @param filePath
  the string to parse
  @return the path containing only the filename itself