What is base64Binary and how can I create base64Binary from a given byte array in Java?
-
http://en.wikipedia.org/wiki/Base64 – Mitch Wheat Aug 11 '11 at 15:32
-
1http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/Base64.html – Mitch Wheat Aug 11 '11 at 15:32
-
1why do you need base64 *binary*, the idea it is that's plains ASCII text. other that http://stackoverflow.com/questions/5908574/base64-decoding-using-jdk6-only might give you an idea – bestsss Aug 11 '11 at 15:33
-
1@bestsss: It's an XSD data type - the weird name originates there. – emboss Aug 11 '11 at 18:54
2 Answers
Try commons-codec with public static byte[] encodeBase64(byte[] binaryData)
.

- 1,720
- 9
- 14
-
-
See Maven repo: http://mvnrepository.com/artifact/commons-codec/commons-codec/1.10. If using Gradle: add this line into build.gradle: compile "commons-codec:commons-codec:1.10" – Jarno Argillander Dec 02 '15 at 09:14
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].

- 38,880
- 7
- 101
- 108