public static String cutToIndexOf(String string,String substring){
  int i=string.indexOf(substring);
  if (i != -1) {
    string=string.substring(0,i);
  }
  return string;
}

public static String cutToIndexOf ( String string , String substring ) { int i = string . indexOf ( substring ) ; if ( i != - 1 ) { string = string . substring ( 0 , i ) ; } return string ; }
cuts the string from beginning to the first index of provided substring .
