Here you can find the source of substringBefore(String str, String separator)
public static String substringBefore(String str, String separator)
//package com.java2s; // BSD-style license that can be found in the LICENSE file. public class Main { /**/*from w ww . j a v a 2 s . c o m*/ * @return the the substring before the first occurrence of a separator. */ public static String substringBefore(String str, String separator) { int index = str.indexOf(separator); if (index == -1) { return str; } return str.substring(0, index); } }