Here you can find the source of substringBefore(final String str, final String separator)
public static String substringBefore(final String str, final String separator)
//package com.java2s; //License from project: Open Source License public class Main { public static String substringBefore(final String str, final String separator) { if (str == null || str.length() == 0) { return str; }/*from w ww . ja va 2s .c o m*/ if (separator == null || str.indexOf(separator) == -1) { return str; } return str.substring(0, str.indexOf(separator)); } }