java 如何创建base64Binary数据?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7028615/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create base64Binary data?
提问by siva636
What is base64Binary and how can I create base64Binary from a given byte array in Java?
什么是 base64Binary 以及如何从 Java 中的给定字节数组创建 base64Binary?
采纳答案by Matthijs Bierman
Try commons-codecwith public static byte[] encodeBase64(byte[] binaryData)
.
试着公地编解码器与public static byte[] encodeBase64(byte[] binaryData)
。
回答by emboss
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.
要创建此类数据,您可以使用 JDK 内置类sun.misc.BASE64Encoder。不幸的是,它不是公共 API,因为没有人愿意在公共 API 中提供 BASE64 编码器/解码器——但人们经常使用这个类来规避这个缺点。
base64Binaryis an XML Schema data type, referring to arbitrary binary data that is to be encoded using BASE64 encodingto retrieve a "safe" string representation of that data - e.g. for embedding binary data in XML, mails etc.
base64Binary是一种 XML 模式数据类型,指的是要使用BASE64 编码进行编码的任意二进制数据,以检索该数据的“安全”字符串表示 - 例如,用于在 XML、邮件等中嵌入二进制数据。
W3C Definition:
W3C 定义:
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].
base64Binary 表示 Base64 编码的任意二进制数据。base64Binary 的·值空间·是二进制八位字节的有限长度序列的集合。对于 base64Binary 数据,整个二进制流使用 [RFC 2045] 中的 Base64 字母表进行编码。