Here you can find the source of truncateString(String description, int length)
Parameter | Description |
---|---|
description | a parameter |
public static String truncateString(String description, int length)
//package com.java2s; /******************************************************************************* * Copyright (c) 2006, 2007 Bug Labs, Inc.. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.buglabs.net/legal/epl_license.html *******************************************************************************/ public class Main { /**//from w w w. ja v a2 s.c o m * Will truncated the string to 35 characters in length adding an ellipsis * for the last three characters. * * @param description * @return */ public static String truncateString(String description, int length) { String truncated = ""; if (description.length() > length) { truncated = description.substring(0, length - 3); truncated = truncated + "..."; } else { truncated = description; } return truncated; } }