public static int lengthWithoutLinefeed ( CharSequence line ) { int length = line . length ( ) ; while ( length > 0 ) { char last = line . charAt ( length - 1 ) ; if ( last != ' ' && last != ' ' ) { break ; } -- length ; } return length ; }
Get the length of the string not taking trailing linefeeds into account .