Here you can find the source of shortenString(String string, int minimumLength, int lengthToShortenBy)
public static String shortenString(String string, int minimumLength, int lengthToShortenBy)
//package com.java2s; public class Main { public static String shortenString(String string, int minimumLength, int lengthToShortenBy) { int minIndex = Math.min(string.length(), minimumLength); int maxIndex = string.length() - lengthToShortenBy; return string.substring(0, Math.max(minIndex, maxIndex)); }//from w w w.j a v a 2 s . co m }