public class Base64Utils extends Object
BASE64编码解码工具包
依赖javabase64-1.3.1.jar
| 构造器和说明 |
|---|
Base64Utils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
byteArrayToFile(byte[] bytes,
String filePath)
二进制数据写文件
|
static byte[] |
decode(String base64)
BASE64字符串解码为二进制数据
|
static void |
decodeToFile(String filePath,
String base64)
BASE64字符串转回文件
|
static String |
encode(byte[] bytes)
二进制数据编码为BASE64字符串
|
static String |
encodeFile(String filePath)
将文件编码为BASE64字符串
大文件慎用,可能会导致内存溢出
|
static byte[] |
fileToByte(String filePath)
文件转换为二进制数组
|
public static byte[] decode(String base64) throws Exception
BASE64字符串解码为二进制数据
base64 - xxxException - xxxpublic static String encode(byte[] bytes) throws Exception
二进制数据编码为BASE64字符串
bytes - xxxException - xxxpublic static String encodeFile(String filePath) throws Exception
将文件编码为BASE64字符串
大文件慎用,可能会导致内存溢出
filePath - 文件绝对路径Exception - xxxxpublic static void decodeToFile(String filePath, String base64) throws Exception
BASE64字符串转回文件
filePath - 文件绝对路径base64 - 编码字符串Exception - xxxxpublic static byte[] fileToByte(String filePath) throws Exception
文件转换为二进制数组
filePath - 文件路径Exception - xxxxCopyright © 2016. All rights reserved.