Here you can find the source of substringBeforeLast(String str, String separator)
public static String substringBeforeLast(String str, String separator)
//package com.java2s; //License from project: Apache License public class Main { public static String substringBeforeLast(String str, String separator) { if (str == null || separator == null || str.length() == 0 || separator.length() == 0) { return str; }/*ww w .j a v a2 s . c om*/ int pos = str.lastIndexOf(separator); if (pos == -1) { return str; } return str.substring(0, pos); } }