public static String decodeAmpersand ( String s ) { if ( s == null || s . indexOf ( ' ' ) == - 1 ) return ( s ) ; StringBuilder result = new StringBuilder ( ) ; int [ ] eatLength = new int [ 1 ] ; // add this in order to multithread safe while ( s . length ( ) != 0 ) { char c = eatAmpersand ( s , eatLength ) ; if ( eatLength [ 0 ] > 1 ) { result . append ( c ) ; s = s . substring ( eatLength [ 0 ] ) ; } else { result . append ( s . charAt ( 0 ) ) ; s = s . substring ( 1 ) ; } } return ( result . toString ( ) ) ; }
Decodes all ampersand sequences in the string