Decoding a Base64 string in Java

前端 未结 4 1709
心在旅途
心在旅途 2020-12-05 09:15

I\'m trying to decode a simple Base64 string, but am unable to do so. I\'m currently using the org.apache.commons.codec.binary.Base64 package.

The test

4条回答
  •  萌比男神i
    2020-12-05 09:50

    Modify the package you're using:

    import org.apache.commons.codec.binary.Base64;
    

    And then use it like this:

    byte[] decoded = Base64.decodeBase64("YWJjZGVmZw==");
    System.out.println(new String(decoded, "UTF-8") + "\n");
    

提交回复
热议问题