public static String strip ( final String s ) { int first ; int last ; for ( first = 0 ; first < s . length ( ) ; first ++ ) { if ( ! Character . isWhitespace ( s . charAt ( first ) ) ) { break ; } } for ( last = s . length ( ) ; last > first ; last -- ) { if ( ! Character . isWhitespace ( s . charAt ( last - 1 ) ) ) { break ; } } return s . substring ( first , last ) ; }
Removes the trailing and leading whitespaces