由于javax.xml.bind
模块在Java 9中被弃用,因此可以使用org.apache.commons.codec.binary.Base64
类进行转换。
JAVA 8
byte[] imageBytes = javax.xml.bind.DatatypeConverter.DatatypeConverter.parseBase64Binary(base64ImageString);
JAVA 9
byte[] data = org.apache.commons.codec.binary.Base64.decodeBase64(crntImage);
如果你的base64图片带前缀data:image/png;base64,iVBORw0...
,那你需要移除这部分:
String base64Image = imgStr.split(",")[1];
更详细内容请参考:
- Java中Base64类型的字符串与图片的相互转换;
- Convert base64 string to image;
- Write Base64-encoded image to file;
- DatatypeConverter vs Base64;
最新评论
能弄个电视apk 就好了
求分享站点。https://www.ziyedm.com 子夜动漫 无广告,更新及时
+62 +63 都不行 一直邮箱 验证也上不去 要么就呼叫来电 或者发送到另一台设备 但是另一台设备没有收到码 这个文章也看过了
telegram x接不到验证码