Here you can find the source of truncateString(String errCode, int length, boolean isRight)
public static String truncateString(String errCode, int length, boolean isRight)
//package com.java2s; //License from project: Apache License public class Main { public static String truncateString(String errCode, int length, boolean isRight) { if (!isEmpty(errCode)) { if (length >= errCode.length()) { return errCode; } else { String subString = ""; if (isRight) { subString = errCode.substring(0, length); return subString; } else { subString = errCode.substring(errCode.length() - length, errCode.length()); return subString; }/*w w w. ja va 2 s. com*/ } } return errCode; } public static boolean isEmpty(String str) { if (str == null || str.trim().length() == 0) { return true; } return false; } }