@ Nonnull public static String abbreviate ( String str , int max ) { if ( str == null ) { return "" ; } else if ( str . length ( ) <= max ) { return str ; } else { return str . substring ( 0 , max - 3 ) + "..." ; } }
Abbreviates a String using ellipses . This will turn Now is the time for all good men into Now is the time for ...