Here you can find the source of substringBeforeLast(final String str, final String separator)
public static String substringBeforeLast(final String str, final String separator)
//package com.java2s; //License from project: Open Source License public class Main { private static final int INDEX_NOT_FOUND = -1; public static String substringBeforeLast(final String str, final String separator) { if (isEmpty(str) || isEmpty(separator)) { return str; }//from w w w.j av a2 s.c o m final int pos = str.lastIndexOf(separator); if (pos == INDEX_NOT_FOUND) { return str; } return str.substring(0, pos); } public static boolean isEmpty(final CharSequence cs) { return cs == null || cs.length() == 0; } }