Here you can find the source of subStr(String src, String split)
public static String subStr(String src, String split)
//package com.java2s; public class Main { public static String subStr(String src, String split) { if (!(isEmpty(src))) { int index = src.indexOf(split); if (index >= 0) return src.substring(0, index); }// w w w.java 2 s. c o m return src; } public static boolean isEmpty(String s) { return ((s == null) || ("".equals(s))); } public static String isEmpty(String s, String result) { if ((s != null) && (!(s.equals("")))) return s; return result; } public static boolean equals(String s1, String s2) { if ((isEmpty(s1)) && (isEmpty(s2))) return true; if ((!(isEmpty(s1))) && (!(isEmpty(s2)))) return s1.equals(s2); return false; } }