Here you can find the source of truncate(String message, int length, boolean includeCount)
public static String truncate(String message, int length, boolean includeCount)
//package com.java2s; /*//from w w w . j a v a2 s . c o m * $Id$ * -------------------------------------------------------------------------------------- * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com * * The software in this package is published under the terms of the CPAL v1.0 * license, a copy of which has been included with this distribution in the * LICENSE.txt file. */ public class Main { public static String truncate(String message, int length, boolean includeCount) { if (message == null) { return null; } if (message.length() <= length) { return message; } String result = message.substring(0, length) + "..."; if (includeCount) { result += "[" + length + " of " + message.length() + "]"; } return result; } }