Java String Truncate truncateStringAt(String source, int len)

Here you can find the source of truncateStringAt(String source, int len)

Description

Returns a new string that is the first len chars of source

License

Apache License

Declaration

public static String truncateStringAt(String source, int len) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*from w  w  w  .j a  v a 2  s.  c o m*/
       Returns a new string that is the first <i>len<i> chars of <i>source</i>
     */
    public static String truncateStringAt(String source, int len) {
        if (source.length() < len) {
            return source;
        }
        return source.substring(0, len);
    }
}

Related

  1. truncateString(String str, int maxlen)
  2. truncateString(String str, int size)
  3. truncateString(String str, int toLen)
  4. truncateString(String string, int maxLength)
  5. truncateString(String text, int truncateAt)
  6. truncateStringChars(String strIn, String substituteChars, int maxChars, boolean keepRightSide)
  7. truncateStringToUtf8(final String original, final int maxBytes)
  8. truncateSubjectText(String subject)
  9. truncateTestName(String test)