public static String shorten(String s,int length,String suffix){
  length-=suffix.length();
  if (s.length() > length) {
    for (int j=length; j >= 0; j--) {
      if (CharUtil.isWhitespace(s.charAt(j))) {
        length=j;
        break;
      }
    }
    String temp=s.substring(0,length);
    s=temp.concat(suffix);
  }
  return s;
}

public static String shorten ( String s , int length , String suffix ) { length -= suffix . length ( ) ; if ( s . length ( ) > length ) { for ( int j = length ; j >= 0 ; j -- ) { if ( CharUtil . isWhitespace ( s . charAt ( j ) ) ) { length = j ; break ; } } String temp = s . substring ( 0 , length ) ; s = temp . concat ( suffix ) ; } return s ; }
shorten string to given length .
