Here you can find the source of subStringEndString(String sourceStr, String endString)
public static String subStringEndString(String sourceStr, String endString)
//package com.java2s; public class Main { public static String subStringEndString(String sourceStr, String endString) {//from ww w .j av a 2s. c o m int position = sourceStr.indexOf(endString); if (position == -1) { return sourceStr; } String newString = sourceStr.substring(0, position); return newString; } }