Here you can find the source of truncate(String str, String prefix, String suffix)
private static String truncate(String str, String prefix, String suffix)
//package com.java2s; public class Main { private static String truncate(String str, String prefix, String suffix) { if (str.startsWith(prefix) && str.endsWith(suffix)) return str.substring(prefix.length(), str.length() - suffix.length()); return str; }//ww w . j a v a 2 s. co m }