StrUtils { public static String cutMiddleStr(String origin, String middle) { String[] strs; return (strs = origin.split(middle))[strs.length - 1]; } private  StrUtils(); static String fillWithZero(Number aim, int num); static String getMainValue(String suppressCode, int headIndex, String needRemoved); static boolean isEmpty(final String s); static boolean isNotEmpty(final String s); static boolean isBlank(String s); static boolean isNotBlank(String s); static String cutStartStr(String origin, String start); static String cutMiddleStr(String origin, String middle); static String cutTailStr(String origin, String tail); static LinkedList<String> splitMulti(String origin, final String... separators); static boolean isLike(final String origin, final String aim, final String... ignores); static boolean isNumber(final String s); static String str2Hex(String s); static String hex2Str(String s); static String compression(String s); static final String ZERO; static final String HEX; static final String COLON; static final String COMMA; static final String DOUBLE_TRANSFER; static final String PLUS; static final String MINUS; static final char POINT; static final String NEXT_LINE; }
@Test public void cutMiddle() { assertEquals(File.separator + "com" + File.separator + "yuzhouwan" + File.separator + "common" + File.separator + "util" + File.separator + "StrUtilsTest.class", cutMiddleStr("F:" + File.separator + "如何成为 Java 高手" + File.separator + "笔记" + File.separator + "Soft Engineering" + File.separator + "Git" + File.separator + "[code]" + File.separator + "yuzhouwan" + File.separator + "yuzhouwan-common" + File.separator + "target" + File.separator + "test-classes" + File.separator + ".." + File.separator + "test-classes" + File.separator + "com" + File.separator + "yuzhouwan" + File.separator + "common" + File.separator + "util" + File.separator + "StrUtilsTest.class", "test-classes")); }