Here you can find the source of substringAfterLast(String str, String separator)
public static String substringAfterLast(String str, String separator)
//package com.java2s; //License from project: Apache License public class Main { public static String substringAfterLast(String str, String separator) { if (isEmpty(str)) { return str; }//from w w w.j ava2 s . com if (isEmpty(separator)) { return ""; } int pos = str.lastIndexOf(separator); if ((pos == -1) || (pos == str.length() - separator.length())) { return ""; } return str.substring(pos + separator.length()); } public static boolean isEmpty(String str) { return (str == null) || (str.length() == 0); } public static int lastIndexOf(String str, char searchChar) { if (isEmpty(str)) { return -1; } return str.lastIndexOf(searchChar); } public static int lastIndexOf(String str, char searchChar, int startPos) { if (isEmpty(str)) { return -1; } return str.lastIndexOf(searchChar, startPos); } public static int lastIndexOf(String str, String searchStr) { if ((str == null) || (searchStr == null)) { return -1; } return str.lastIndexOf(searchStr); } public static int lastIndexOf(String str, String searchStr, int startPos) { if ((str == null) || (searchStr == null)) { return -1; } return str.lastIndexOf(searchStr, startPos); } public static String substring(String str, int start) { if (str == null) { return null; } if (start < 0) { start = str.length() + start; } if (start < 0) { start = 0; } if (start > str.length()) { return ""; } return str.substring(start); } public static String substring(String str, int start, int end) { if (str == null) { return null; } if (end < 0) { end = str.length() + end; } if (start < 0) { start = str.length() + start; } if (end > str.length()) { end = str.length(); } if (start > end) { return ""; } if (start < 0) { start = 0; } if (end < 0) { end = 0; } return str.substring(start, end); } }