How to create base64Binary data?

2020-08-25 05:40发布

What is base64Binary and how can I create base64Binary from a given byte array in Java?

2条回答
闹够了就滚
2楼-- · 2020-08-25 05:53

To create such data you may use the JDK built-in class sun.misc.BASE64Encoder. Unfortunately it's not public API since nobody cared to provide a BASE64 en-/decoder in the public API - but people often use this class to circumvent that disadvantage.

base64Binary is an XML Schema data type, referring to arbitrary binary data that is to be encoded using BASE64 encoding to retrieve a "safe" string representation of that data - e.g. for embedding binary data in XML, mails etc.

W3C Definition:

base64Binary represents Base64-encoded arbitrary binary data. The ·value space· of base64Binary is the set of finite-length sequences of binary octets. For base64Binary data the entire binary stream is encoded using the Base64 Alphabet in [RFC 2045].

查看更多
The star\"
3楼-- · 2020-08-25 06:08

Try commons-codec with public static byte[] encodeBase64(byte[] binaryData).

查看更多
登录 后发表回答