public static String trimTextDown ( String text , int sizeMinusAppend , String append ) { Assert . notNull ( append , "Missing append!" ) ; if ( text == null || text . length ( ) <= sizeMinusAppend ) { return text ; } sizeMinusAppend = sizeMinusAppend - append . length ( ) ; int pos = text . lastIndexOf ( " " , sizeMinusAppend ) ; if ( pos < 0 ) { return text . substring ( 0 , sizeMinusAppend ) + append ; } return text . substring ( 0 , pos ) + append ; }
Reduces text size to a given size