How can I convert an image to a base64 string using Java?(如何使用 Java 将图像转换为 base64 字符串?)
问题描述
正如标题所示,我想知道如何在 Java 中将图像转换为 base64 字符串.我该怎么做?
As the title indicates, I want to know how to convert an image to a base64 string in Java. How can I do this?
推荐答案
使用Base64
类.
如果您使用的是 Java 8 之前的版本,请查看以下资源之一:
If you're on pre-Java 8, have a look at one of the following resources:
exampledepot.com 上的示例
或 Base64Coder - Java 中的开源 Base64 编码器/解码器一个>
或 Base64 类在 org.apache.commons.codec.binary 包中
这篇关于如何使用 Java 将图像转换为 base64 字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!