Android String Sub String Get subString(String str, int length)

Here you can find the source of subString(String str, int length)

Description

sub String

Declaration

public static String subString(String str, int length) 

Method Source Code

//package com.java2s;

public class Main {

    public static String subString(String str, int length) {
        if (isBlank(str)) {
            return "";
        } else if (str.length() > length) {
            return str.substring(0, length);
        } else {/*w ww  .j a va 2 s  .  com*/
            return str;
        }
    }

    public static boolean isBlank(String str) {
        if (null == str)
            return true;
        if ("".equals(str.trim()))
            return true;

        return false;
    }

    public static boolean isBlank(Long str) {
        if (null == str)
            return true;
        return false;
    }
}

Related

  1. getTailorString(String string, int length)
  2. mid(String str, int beginIndex, int length)
  3. subStringByByte(String str, int startPos, int length)
  4. subStringByByte(String paramString, int beginIndex, int endIndex)
  5. subString(String source, String start, int offsetStart, String end, int offsetEnd)
  6. subInStringByFlag(String str, String flag)
  7. substringWithoutException(String text, int startIndex, int endIndex)
  8. subString(String str)
  9. replace(String s, String oldSub, String newSub)