图片转Base64
来源:互联网 发布:三维彩超上数据看男女 编辑:程序博客网 时间:2024/06/05 18:27
/**
* encodeBase64File:(将文件转成base64 字符串). <br/>
*
* @param path 文件路径
* @return
* @throws Exception
* @author guhaizhou@126.com
* @since JDK 1.6
*/
public static String encodeBase64File(String path) throws Exception {
File file = new File(path);
FileInputStream inputFile = new FileInputStream(file);
byte[] buffer = new byte[(int) file.length()];
inputFile.read(buffer);
inputFile.close();
return Base64.encodeToString(buffer, Base64.DEFAULT);
* encodeBase64File:(将文件转成base64 字符串). <br/>
*
* @param path 文件路径
* @return
* @throws Exception
* @author guhaizhou@126.com
* @since JDK 1.6
*/
public static String encodeBase64File(String path) throws Exception {
File file = new File(path);
FileInputStream inputFile = new FileInputStream(file);
byte[] buffer = new byte[(int) file.length()];
inputFile.read(buffer);
inputFile.close();
return Base64.encodeToString(buffer, Base64.DEFAULT);
}
/**
* decoderBase64File:(将base64字符解码保存文件). <br/>
*
* @param base64Code 编码后的字串
* @param savePath 文件保存路径
* @throws Exception
* @author guhaizhou@126.com
* @since JDK 1.6
*/
public static void decoderBase64File(String base64Code, String savePath) throws Exception {
//byte[] buffer = new BASE64Decoder().decodeBuffer(base64Code);
byte[] buffer = Base64.decode(base64Code, Base64.DEFAULT);
FileOutputStream out = new FileOutputStream(savePath);
out.write(buffer);
out.close();
}
* decoderBase64File:(将base64字符解码保存文件). <br/>
*
* @param base64Code 编码后的字串
* @param savePath 文件保存路径
* @throws Exception
* @author guhaizhou@126.com
* @since JDK 1.6
*/
public static void decoderBase64File(String base64Code, String savePath) throws Exception {
//byte[] buffer = new BASE64Decoder().decodeBuffer(base64Code);
byte[] buffer = Base64.decode(base64Code, Base64.DEFAULT);
FileOutputStream out = new FileOutputStream(savePath);
out.write(buffer);
out.close();
}
0 0
- base64转图片 图片转base64
- base64转图片 图片转base64
- 图片转Base64
- 图片转base64字符串
- android 图片转 Base64
- 图片转Base64位
- java base64转图片
- Base64编码转图片
- javascript 图片转base64
- 图片转Base64编码
- 图片转Base64
- 图片转base64文字
- base64 图片互转
- img图片转base64
- JAVA图片转base64
- base64转图片
- 图片url转base64
- base64图片字符串转图片
- 漫谈一下前端的可视化技术
- 10个TWaver网页3D可视化精彩案例
- Random Decision Forest
- X1 Carbon wifi 8260 无线网卡驱动安装 backports
- vim 一些有用的删除操作
- 图片转Base64
- 原型、原型链
- [iOS Xib加载/封装] xib加载以后无法赋值Laber属性的值
- svn忽略ignore文件记住方式
- @Autowired 与@Resource的区别 及@Autowired 在成员变量和set方法的区别
- http中Last-Modified 与If-Modified-Since的说明
- abstract不可以和哪些关键字共存
- 你不必使用弱引用以避免内存泄漏
- HashMap和Hashtable的区别