Java XML String Transform base64encode(String decodedString)

Here you can find the source of base64encode(String decodedString)

Description

baseencode

License

Open Source License

Parameter

Parameter Description
decodedString a parameter

Declaration

public static String base64encode(String decodedString) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.xml.bind.DatatypeConverter;

public class Main {
    /**/*from   ww w. j  a v  a2 s  .  c  om*/
     * @param decodedString
     */
    public static String base64encode(String decodedString) {
        return DatatypeConverter.printBase64Binary(decodedString.getBytes());
    }

    /**
     * @param decodedString
     */
    public static String base64encode(byte[] bytes) {
        return DatatypeConverter.printBase64Binary(bytes);
    }

    /**
     * Transform the length into the 32-bit message length.
     * 
     * @param length
     * @return
     */
    public static byte[] getBytes(int length) {
        byte[] bytes = new byte[4];
        bytes[0] = (byte) (length & 0xFF);
        bytes[1] = (byte) ((length >> 8) & 0xFF);
        bytes[2] = (byte) ((length >> 16) & 0xFF);
        bytes[3] = (byte) ((length >> 24) & 0xFF);
        return bytes;
    }
}

Related

  1. addElementToXml(String xmlFile, String nodeToAdd, String nodeContent)
  2. addNode(String nodeType, String idField, String nodeID, File destFile, ArrayList attributes)
  3. applyXSL(File xmlFile, File xslFile, String outputFilename)
  4. convertPlist(File info_plist_file, String script_url, Map script_parameters)
  5. convertResult(StreamResult result, StringWriter writer)
  6. convertValidatorResult(Result result, StringWriter writer)
  7. createElement(Node node, String name, String value, Map attributes)