Java tutorial
//package com.java2s; public class Main { public static String limitMessage(String str, int limit) { if (str.length() <= limit) { return str; } else { StringBuilder sb = new StringBuilder(str.substring(0, limit)); sb.append("..."); return sb.toString(); } } }