private static String cleanString ( String field ) { int size = field . length ( ) ; StringBuilder sb = new StringBuilder ( size ) ; for ( int i = 0 ; i < size ; i ++ ) { char nextChar = field . charAt ( i ) ; switch ( nextChar ) { case HttpConstants . COLON : case HttpConstants . COMMA : case HttpConstants . EQUALS : case HttpConstants . SEMICOLON : case HttpConstants . HT : sb . append ( HttpConstants . SP_CHAR ) ; break ; case HttpConstants . DOUBLE_QUOTE : // nothing added, just removes it break ; default : sb . append ( nextChar ) ; break ; } } return sb . toString ( ) . trim ( ) ; }
Clean the String from any unallowed character