public static String trim ( String input , int maxNrofChars , String end ) { if ( end == null ) { end = "" ; } int margin = end . length ( ) ; if ( input != null && input . length ( ) > maxNrofChars + margin ) { input = input . substring ( 0 , maxNrofChars ) + end ; } return input ; }
Trims strings that contain too many characters and adds trailing characters to indicate that the original string has been trimmed .