public static String before(String s,String token){
  if (s == null) {
    return null;
  }
  int i=s.indexOf(token);
  if (i == -1) {
    return s;
  }
  return s.substring(0,i);
}

public static String before ( String s , String token ) { if ( s == null ) { return null ; } int i = s . indexOf ( token ) ; if ( i == - 1 ) { return s ; } return s . substring ( 0 , i ) ; }
returns the part of s before the token . < p / > < br / > example : before ( " helloworldthisisme " , " world " ) will return " hello " . < br / > example : before ( " helloworldthisisme " , " dog " ) will return " helloworldthisisme " . < p / > if the token is not in the string , the entire string is returned .
