Here you can find the source of cutText(String text, int maxLength)
public static final String cutText(String text, int maxLength)
//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; } }