public String decode ( String text ) { if ( text == null ) { return null ; } if ( ( ! text . startsWith ( Prefix ) ) || ( ! text . endsWith ( Postfix ) ) ) throw new IllegalArgumentException ( "RFC 1522 violation: malformed encoded content" ) ; int terminator = text . length ( ) - 2 ; int from = 2 ; int to = text . indexOf ( Sep , from ) ; if ( to == terminator ) throw new IllegalArgumentException ( "RFC 1522 violation: charset token not found" ) ; String charset = text . substring ( from , to ) ; if ( charset . equals ( "" ) ) throw new IllegalArgumentException ( "RFC 1522 violation: charset not specified" ) ; from = to + 1 ; to = text . indexOf ( Sep , from ) ; if ( to == terminator ) throw new IllegalArgumentException ( "RFC 1522 violation: encoding token not found" ) ; String encoding = text . substring ( from , to ) ; if ( ! getEncoding ( ) . equalsIgnoreCase ( encoding ) ) throw new IllegalArgumentException ( "This codec cannot decode " + encoding + " encoded content" ) ; from = to + 1 ; to = text . indexOf ( Sep , from ) ; return new String ( Base64 . decode ( text . substring ( from , to ) . toCharArray ( ) ) , Charset . forName ( charset ) ) ; }
Decodes a Base64 string into its original form . Escaped characters are converted back to their original representation .