2012-07-13 53 views

回答

2
import sun.misc.BASE64Decoder; 

BASE64Decoder decoder = new BASE64Decoder(); 
byte[] imageByte = decoder.decodeBuffer(imageData); 

其中imageData是包含Base64數據的字符串。

+1

BASE64Decoder從哪裏來? – Thilo 2012-07-13 06:23:43

+0

sun.misc.BASE64Decoder – Taha 2012-07-13 06:25:31

+0

http://stackoverflow.com/a/469739/1793718 – Lucky 2015-05-29 13:03:18

11

您也可以使用Apache共享編解碼器(​​)

String example = "SGVsbG8gV29ybGQ=" 
byte[] decoded = org.apache.commons.codec.binary.Base64.decodeBase64(example .getBytes()); 
+0

謝謝你的哥們。 Java的股票解析器不適合我。這工作。 :) – plkmthr 2015-06-10 14:06:30

+1

從Java 8開始,您可以使用內置的'java.util.Base64'。 – karl 2017-02-22 08:59:18