Here you can find the source of truncate(String message)
public static String truncate(String message)
//package com.java2s; //License from project: Apache License public class Main { public static String truncate(String message) { if (message.lastIndexOf(".") < 500 && message.lastIndexOf(".") != -1) { return message.substring(0, message.lastIndexOf(".")); }//w w w .j a v a 2 s . c o m message = message.substring(0, 495); //this one can cut quite a lot of stuff.. if (message.lastIndexOf(".") < 500 && message.lastIndexOf(".") != -1) { return message.substring(0, message.lastIndexOf(".")); } return message + "..."; } }