Here you can find the source of shortenToFirstLast(String filename)
public static String shortenToFirstLast(String filename)
//package com.java2s; //License from project: Open Source License public class Main { public static String shortenToFirstLast(String filename) { if ((filename == null) || (filename.length() < 2)) { return filename; }// www .j a va2s .c o m final int firstIndex = filename.indexOf('/', 1); final int lastIndex = filename.lastIndexOf('/'); if ((firstIndex < 0) || (firstIndex == lastIndex)) { return filename; } String result = filename.substring(0, firstIndex) + filename.substring(lastIndex); return result; } }