Java String Truncate truncate(String value, int length)

Here you can find the source of truncate(String value, int length)

Description

Truncate the given string

License

Open Source License

Parameter

Parameter Description
value is the String to truncate
length is the truncate length

Return

truncate string

Declaration

public static String truncate(String value, int length) 

Method Source Code

//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;
    }
}

Related

  1. truncate(String text, int truncatedLength)
  2. truncate(String toTruncate, int maxSize)
  3. truncate(String url, int offset, int size)
  4. Truncate(String v, int length)
  5. truncate(String val, int maxlen)
  6. truncate(String value, int length)
  7. truncate(String value, int length)
  8. truncate(String value, int length)
  9. truncate(String value, int maxLen, String ellipses)