我们可以将字节数组转换为Java中的InputStream吗?我一直在网上看,但找不到它。

我有一个以InputStream为参数的方法。

我有的InputStream cph 是base64编码所以我必须使用

解码它
BASE64Decoder decoder = new BASE64Decoder();
byte[] decodedBytes = decoder.decodeBuffer(cph);

现在如何将 decodingBytes 再次转换为 InputStream

其他提示

如果您使用 Robert Harder的Base64实用程序,那么您可以:

InputStream is = new Base64.InputStream(cph);

或者使用太阳的JRE,你可以这样做:

InputStream is = new
com.sun.xml.internal.messaging.saaj.packaging.mime.util.BASE64DecoderStream(cph)

然而,不要依赖那个继续成为JRE一部分的课程,或者甚至继续做它今天似乎做的事情。孙说不要用它。

还有其他有关Base64解码的Stack Overflow问题,例如此问题。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top