Android String Cut cutText(String text, int maxLength)

Here you can find the source of cutText(String text, int maxLength)

Description

cut Text

Declaration

public static final String cutText(String text, int maxLength) 

Method Source Code

//package com.java2s;

public class Main {
    public static final String cutText(String text, int maxLength) {
        if (isEmpty(text) || maxLength < 0) {
            return text;
        }//  www . j  a  v a 2 s  . c  o  m
        int length = text.length();
        if (length > maxLength) {
            return text.substring(0, maxLength);
        }
        return text;
    }

    public static boolean isEmpty(String text) {
        if (text == null || text.length() == 0) {
            return true;
        }
        return false;
    }
}

Related

  1. cutString(String source, String output, int slength)
  2. cutString(String source, int slength)
  3. safeCut(String str, int length)
  4. safeCutNoDot(String str, int length)
  5. cutString(String str, int length)
  6. cutString(String str, int length, String dot)