Here you can find the source of substring(String str, String delim)
public static String substring(String str, String delim)
//package com.java2s; //License from project: Apache License public class Main { public static String substring(String str, String delim) { return substring(str, delim, false); }//from w ww . j a v a 2 s . com public static String substring(String str, String delim, boolean isLast) { if (isNull(delim) || isNull(str)) { return str; } if (isLast) { return str.substring(str.lastIndexOf(delim) + 1); } else { return str.substring(0, str.indexOf(delim)); } } public static boolean isNull(String str) { if (str == null || str.length() < 1) { return true; } return false; } }