private static byte [ ] checkIllegalCharacters ( final byte [ ] bytes ) { final ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; for ( final byte byt : bytes ) { if ( BASE64CHARS . indexOf ( byt ) < 0 ) { out . write ( byt ) ; } } return out . toByteArray ( ) ; }
Check the byte array for non - Base64 characters .