It was almost correct just change your last line like:
String stopEnd = stop.substring(0, stop.length() - 1); //replace stopName with stop.
OR
you can replace your last two lines;
String stopEnd = stopName.substring(0, stopName.length() - 2);