Here you can find the source of truncateAndTrim0(String str, String delim)
public static String truncateAndTrim0(String str, String delim)
//package com.java2s; //License from project: Open Source License public class Main { public static String truncateAndTrim0(String str, String delim) { if (str == null || delim == null) { return str; }// ww w . ja v a 2s . c o m int nStart = str.indexOf(delim); if (nStart < 0) { return str; } return str.substring(0, nStart); } }