code: public static String substringBefore(String text, char stopper) {
          int p = text.indexOf(stopper);
          return p < 0 ? text : text.substring(0, p);
      }
docs: Returns a substring from position 0 up to just before the stopper character.
  
  @param text - a text string
  @param stopper - a stopper character
  @return the substring