Here you can find the source of subInStringByFlag(String str, String flag)
public static String subInStringByFlag(String str, String flag)
//package com.java2s; public class Main { public static String subInStringByFlag(String str, String flag) { if (isBlank(str)) return null; StringBuffer sb = new StringBuffer(str); int index = str.lastIndexOf(flag); if (index < 0) { return str; } else {/* w w w . j a v a 2 s.co m*/ str = sb.delete(sb.length() - flag.length(), sb.length()) .toString(); index = str.indexOf(flag); if (index < 0) { return str; } else { return sb.deleteCharAt(0).toString(); } } } public static boolean isBlank(String str) { if (null == str) return true; if ("".equals(str.trim())) return true; return false; } public static boolean isBlank(Long str) { if (null == str) return true; return false; } public static String toString(Object obj) { if (obj == null) { return ""; } return obj.toString().trim(); } }