private static int discardWhitespace ( byte [ ] data ) { final int length = data . length ; int i = 0 ; while ( i < length ) { byte c = data [ i ++ ] ; if ( c == ( byte ) ' ' || c == ( byte ) ' ' || c == ( byte ) ' ' || c == ( byte ) ' ' ) { int count = i - 1 ; while ( i < length ) { c = data [ i ++ ] ; if ( c != ( byte ) ' ' && c != ( byte ) ' ' && c != ( byte ) ' ' && c != ( byte ) ' ' ) { data [ count ++ ] = c ; } } return count ; } } return length ; }
Discards any whitespace from a base - 64 encoded block . The base64 data in responses could be chunked in the multiple lines so we need to remove extra whitespaces . The bytes are copied in - place and the length of the actual data bytes is returned .