Java XML Base64 Encode Decode encodeBase64(String stringValue)

Here you can find the source of encodeBase64(String stringValue)

Description

encode Base

License

Open Source License

Declaration

public static String encodeBase64(String stringValue)
            throws NoSuchAlgorithmException, UnsupportedEncodingException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2011, 2016 Eurotech and/or its affiliates and others
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:// w w w.  j av  a 2 s  .com
 *     Eurotech - initial API and implementation
 *
 *******************************************************************************/

import java.io.UnsupportedEncodingException;

import java.security.NoSuchAlgorithmException;

import javax.xml.bind.DatatypeConverter;

public class Main {
    public static String encodeBase64(String stringValue)
            throws NoSuchAlgorithmException, UnsupportedEncodingException {
        byte[] bytesValue = stringValue.getBytes("UTF-8");
        String encodedValue = DatatypeConverter.printBase64Binary(bytesValue);
        return encodedValue;

    }
}

Related

  1. decompressFromBase64(String message)
  2. encodeBase64(byte[] b)
  3. encodeBase64(byte[] bytes)
  4. encodeBASE64(byte[] data)
  5. encodeBase64(String input)
  6. encodeBase64Binary(byte[] data)
  7. fromBase64(String base64)
  8. fromBase64(String hex)
  9. getBase64(byte[] bytes)