public void trim ( ) { try { //cut white spaces from the head while ( len > 0 && chars [ pos ] == ' ' ) { pos ++ ; len -- ; } //cut from the end while ( len > 0 && ( chars [ pos + len - 1 ] == ' ' || chars [ pos + len - 1 ] == ' ' || chars [ pos + len - 1 ] == ' ' ) ) { len -- ; } } catch ( Exception e ) { System . out . println ( "len:" + len + ",pos:" + pos ) ; } }
Removes whitespace from the head and tail of the string .