使用apache commons codec做base64编码

commons项目下,有一个codec子项目,可用于做base64编码。该工具还可以做16进制,音标,url的编码,md5和sha加密的摘要等。

在maven中引入:

<dependency>
    <groupId>commons-codec</groupId>
    <artifactId>commons-codec</artifactId>
    <version>1.4</version>
</dependency>

base64的使用很简单,见:

http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/Base64.html

直接使用静态方法:

  • encodeBase64:生成base64编码的字节数组;
  • decodeBase64:根据base64编码生成解码后的文字。
PDF格式打印機    发送文章为PDF   

这篇文章上的评论的 RSS feed TrackBack URI

Leave a Reply