Use Apache StringUtils.substringBeforeLast(..) (instead of custom)