从 MimeMultipart 解码 Base64 内容
我的 MimeMessage
的一部分中有一个 Base64 文件。 我这样说
DataSource source = new FileDataSource(new File("base64Test.bin"));
bodyPart.setDataHandler(new DataHandler(source));
然后,我想使用 BASE64DecoderStream.decode 方法对其进行解码
String base64 = (String)bodyPart.getContent();
byte [] base64Decoder = BASE64DecoderStream.decode(base64.getBytes());
问题在于,当我使用此方法时,我总是遇到 ArrayOutOfboundException 。
为了解决这个问题有什么建议吗?
I have a Base64 file into one part of my MimeMessage
.
I put it like this
DataSource source = new FileDataSource(new File("base64Test.bin"));
bodyPart.setDataHandler(new DataHandler(source));
Then, I want to decode it using the method BASE64DecoderStream.decode
String base64 = (String)bodyPart.getContent();
byte [] base64Decoder = BASE64DecoderStream.decode(base64.getBytes());
The problem with that is that I have always an ArrayOutOfboundexception
when I use this method.
Any advice in order to solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(2)
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
据我所知,Base64DecoderStream 采用 InputStream,而不是字节数组。至少,您需要像这样更改解码:
也许自动装箱正在尝试帮助您,而一些“中间”数组创建正在破坏工作。或者,也许您的消息足够大,以至于无法创建足够大的数组。或者也许您有两个线程调用静态产品,这会弄乱内部共享缓冲区。
As far as I know, a Base64DecoderStream takes an InputStream, not a byte array. At a minimum, you need to change the decoding like so:
Perhaps autoboxing is trying to help you out, and some "intermediate" array creation is fouling the works. Or, maybe your message is just large enough that an array can't be created big enough. Or maybe you have two threads calling the static offering which is messing up internal shared buffers.