Java XML Data Type Converter decode(String string, boolean decode)

Here you can find the source of decode(String string, boolean decode)

Description

decode

License

Apache License

Declaration

public static String decode(String string, boolean decode) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import javax.xml.bind.DatatypeConverter;
import java.io.UnsupportedEncodingException;

public class Main {
    public static String decode(String string, boolean decode) {
        return decode ? decode(string) : string;
    }//from  w ww  . j  a  v  a2s.com

    public static String decode(String string) {
        if (string != null) {
            try {
                byte[] decoded = DatatypeConverter.parseBase64Binary(string);
                return new String(decoded, "UTF-8");
            } catch (UnsupportedEncodingException e) {
            }
        }
        return string;
    }
}

Related

  1. convertToTwoBytes(int numberToConvert)
  2. createBasicAuthenticationProperty(final String username, final String password)
  3. decode(final CharSequence _text)
  4. decode(String auth)
  5. decode(String source)
  6. decodeBasicAuth(String auth)
  7. decodeJavaOpts(String encodedJavaOpts)
  8. decodeToDoubleArray(String encoded)
  9. decrypt(String encryptedText, String password)