Convert base64 String to bytecode in java

Possible duplicate:
Decode Base64 data in java

I am working on a java profile, I want to know how to convert base64 string to byte array. can someone request a code and fule will be useful to me.

+6
source share
2 answers

You can also use Apache Commons Codec ( http://commons.apache.org/codec/ )

String example = "SGVsbG8gV29ybGQ=" byte[] decoded = org.apache.commons.codec.binary.Base64.decodeBase64(example .getBytes()); 
+11
source
 import sun.misc.BASE64Decoder; BASE64Decoder decoder = new BASE64Decoder(); byte[] imageByte = decoder.decodeBuffer(imageData); 

Where imageData is a string containing Base64 data.

+2
source

Source: https://habr.com/ru/post/920388/


All Articles