Java 如何将base64字符串转换为blob?
在Java 如何将base64字符串转换为blob?,java,android,base64,bytearray,blob,Java,Android,Base64,Bytearray,Blob,在Base64字符串中提供图像的同步服务,我想将其保存到SQLite数据库blob字段中 有人能告诉我如何进行这项工作或以其他方式进行这项工作吗 稍后,我需要在位图中显示图像。将base64图像字符串转换为字节[],如: byte[] decodedByte = Base64.decode(yourBase64String, 0); Bitmap bitmap = BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length
Base64
字符串中提供图像的同步服务,我想将其保存到SQLite
数据库blob
字段中
有人能告诉我如何进行这项工作或以其他方式进行这项工作吗
稍后,我需要在位图中显示图像。将base64图像字符串转换为字节[],如:
byte[] decodedByte = Base64.decode(yourBase64String, 0);
Bitmap bitmap = BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
之后,您还可以将其转换为位图:
byte[] decodedByte = Base64.decode(yourBase64String, 0);
Bitmap bitmap = BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
要将base64字符串转换为字节[],可以使用:
byte[] decodedByte = Base64.decode(yourBase64String)
Blob b = new SerialBlob(decodedByte);
要将字节[]转换为blob,可以使用:
byte[] decodedByte = Base64.decode(yourBase64String)
Blob b = new SerialBlob(decodedByte);
将base64转换为位图,然后将位映射为字节[],将此字节[]转换为Db。确保您的列名的类型为blobHave a loot at,我认为我们应该更新:
Byte[]decodedByte=base64.decoder.decode(您的base64string,0)代码>你的Base64String看起来怎么样?有没有可能“137,80,78,71,13,10,26,10,0,0…”我想我们应该更新:byte[]decodedByte=Base64.getDecoder().decode(yourBase64String)代码>