Java tutorial
//package com.java2s; //License from project: LGPL public class Main { public static String abbreviate(String s, int maxLength) { s = String.valueOf(s); // null check if (s.length() > maxLength) { s = s.substring(0, maxLength) + "..."; } return s; } }