java String转base64

 

import org.apache.commons.codec.binary.Base64;

//下载commons-codec-1.11-bin.zip,调用commons-codec-1.11.jar

Base64 base64 = new Base64();
String base64Sign = base64.encodeToString(string.getBytes("UTF-8"));


//其中汉字需要UTF-8处理,否则编码后会乱码。

posted @ 2020-01-16 11:10  Peter.Jones  阅读(12223)  评论(0)    收藏  举报