jcrshankar
jcrshankar

Reputation: 1196

How to convert blob image into binarybase64 in java?

I have image in blob format from DB , i am holding that blob image in byte array and converting it to Binary Base64 format.

For encoding the blob to binary base 64 I am using below code,

 byte[] imageByte = getblob();//from DB
 byte[] encodedImage = Base64.encodeBase64(imageByte);

is there any other way to do it or am doing it in right way please help me?

Upvotes: 1

Views: 17510

Answers (2)

Ahmad Aghazadeh
Ahmad Aghazadeh

Reputation: 17131

Try this code:

   String imgString = Base64.encodeToString(bytes, 
                   Base64.NO_WRAP);

Upvotes: 0

Alok Agarwal
Alok Agarwal

Reputation: 3099

if its not working than you can use

fileData.encode('base64')

this will solve the purpose

Upvotes: 0

Related Questions