Here you can find the source of shorten(String s, int len)
public static String shorten(String s, int len)
//package com.java2s; //License from project: Open Source License public class Main { /**// w w w .j a v a 2 s .com * Shortens the string "s" to a length of "len" characters. */ public static String shorten(String s, int len) { if (s == null) return null; if (s.length() > len) s = s.substring(0, len - 2) + ".."; return s; } /** * Shortens the string "s" to a length of 70 characters. */ public static String shorten(String s) { if (s == null) return null; if (s.length() > 70) s = s.substring(0, 67) + "..."; return s; } }