public static boolean validateIsBase64String ( final String data ) { if ( data == null || data . length ( ) % 4 != 0 ) { return false ; } for ( int m = 0 ; m < data . length ( ) ; m ++ ) { final byte charByte = ( byte ) data . charAt ( m ) ; // pad char detected if ( DECODE_64 [ charByte ] == - 2 ) { if ( m < data . length ( ) - 2 ) { return false ; } else if ( m == data . length ( ) - 2 && DECODE_64 [ ( byte ) data . charAt ( m + 1 ) ] != - 2 ) { return false ; } } if ( charByte < 0 || DECODE_64 [ charByte ] == - 1 ) { return false ; } } return true ; }
Determines whether the given string contains only Base64 characters .