Java String Truncate truncate(final String str, final int len)

Here you can find the source of truncate(final String str, final int len)

Description

truncate

License

Open Source License

Parameter

Parameter Description
str a parameter
len a parameter

Declaration

public static String truncate(final String str, final int len) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from   ww w  .j  av a  2  s.  c o m
     * 
     * @param str
     * @param len
     * @return
     */
    public static String truncate(final String str, final int len) {
        return (str.length() <= len) ? str : str.substring(0, len);
    }
}

Related

  1. trunc(String value, int len)
  2. truncate(final String description)
  3. truncate(final String in, final int maxLen)
  4. truncate(final String originalString, final int maxChars)
  5. truncate(final String s, final int n)
  6. truncate(final String str, final int len)
  7. truncate(final String str, final int maxWidth)
  8. truncate(final String target, final int maxSize)
  9. truncate(final String value, final int width)