Java String Sub String subStr(String str, int maxLen)

Here you can find the source of subStr(String str, int maxLen)

Description

sub Str

License

Open Source License

Declaration

public static String subStr(String str, int maxLen) 

Method Source Code

//package com.java2s;

public class Main {
    public static String subStr(String str, int maxLen) {
        if (str == null) {
            return null;
        }/*from  w  w  w.j  a v a  2s .  c o  m*/
        if (maxLen < 1) {
            return str;
        }
        if (str.length() > maxLen) {
            return str.substring(0, maxLen) + "...";
        }
        return str;
    }
}

Related

  1. substr(String str, int iLen)
  2. substr(String str, int index)
  3. subStr(String str, int len)
  4. substr(String str, int length)
  5. subStr(String str, int limit)
  6. substr(String str, int startIndex, int length)
  7. substr(String substr1, String substr2)
  8. substr(String what, int begin, int end)
  9. substr(StringBuffer buf)