Skip to content

Instantly share code, notes, and snippets.

@xzzz9097
Last active August 29, 2015 14:05
Show Gist options
  • Save xzzz9097/e07432563dcb2ab94185 to your computer and use it in GitHub Desktop.
Save xzzz9097/e07432563dcb2ab94185 to your computer and use it in GitHub Desktop.
Remove part of string - Java
/**
* Quick method to remove a specified part of a string
* @param remove - the string part to remove
* @param from - the original string
* @return - the cut string
*/
public static String removeStringFromString(String remove, String from) {
char lastCharacter = remove.charAt(remove.length() - 1);
int cutStart = from.lastIndexOf(lastCharacter) + 1;
return from.substring(cutStart);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment