Decode Base64 data in Java

前端 未结 20 1839
时光说笑
时光说笑 2020-11-21 06:04

I have an image that is Base64 encoded. What is the best way to decode that in Java? Hopefully using only the libraries included with Sun Java 6.

20条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-21 06:41

    You can simply try this.

    byte[] data = Base64.getDecoder().decode(base64fileContent);
    

    "Base64.getDecode()" returns a Base64 Decoder that can be decoded. Then you need to decode that again using ".decode()"

提交回复
热议问题