Base64编码和解码字符串
Base64编码和解码字符串
package com.example.core.mydemo.cpic; import org.apache.commons.codec.binary.Base64; /** * strEncode=aGVsbG8gd29ybGQ= * strDecode=hello world */ public class BizRequestBase64Test { private static final String CHAR_SET_UTF_8 = "UTF-8"; public static void main(String[] args) throws Exception{ String str = "hello world"; String strEncode = new Base64().encodeToString(str.getBytes(CHAR_SET_UTF_8)); System.out.println("strEncode=" + strEncode); byte[] biz_request = new Base64().decode(strEncode.getBytes(CHAR_SET_UTF_8)); System.out.println("strDecode=" + new String(biz_request)); } }