Here you can find the source of cutWords(String src, String contains)
public static String cutWords(String src, String contains)
//package com.java2s; public class Main { public static String cutWords(String src, String contains) { int begin = src.indexOf(contains); if (begin == -1) { return src; }//from ww w . j a v a 2 s . c o m int end = begin + contains.length(); String beginStr = ""; if (begin != 0) { beginStr = src.substring(0, begin); } String endStr = ""; if (end < src.length()) { endStr = src.substring(end); } return beginStr + endStr; } }