Here you can find the source of shorten(String name, int max)
private static String shorten(String name, int max)
//package com.java2s; //License from project: LGPL public class Main { private static String shorten(String name, int max) { int index = name.indexOf(' '); while (name.length() > max && index != -1) { name = name.substring(index + 1); index = name.indexOf(' '); }/*from w w w . j a v a 2 s .c o m*/ return name; } }