Java tutorial
//package com.java2s; import android.util.Log; public class Main { private static final String TAG = "AqUtils"; public static String removeStringSuffix(String s, String suffix) { String retval = s; if ((null != s) && (null != suffix)) { int sLen = s.length(); int suffixLen = suffix.length(); if (suffixLen <= sLen) { try { String t = s.substring(sLen - suffixLen, sLen); if (suffixLen == sLen) { retval = ""; } else if (suffix.equals(t)) { retval = s.substring(0, sLen - suffixLen - 1); } } catch (Exception e) { //^^FE1=removeSuffix() Log.e(TAG, "^^FE1", e); } } } Log.d(TAG, "AqUtils.removeStringSuffix(). s,suffix,retval: " + s + "," + suffix + "," + retval); return retval; } }