Here you can find the source of truncate(String value, int length)
Parameter | Description |
---|---|
value | is the String to truncate |
length | is the truncate length |
public static String truncate(String value, int length)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w. j a v a 2 s .c o m*/ * Truncate the given string * * @param value * is the String to truncate * @param length * is the truncate length * @return truncate string */ public static String truncate(String value, int length) { if (value != null && value.length() > length) value = value.substring(0, length); return value; } }