如何将outputStream转换为字节数组? [英] How to convert outputStream to a byte array?
本文介绍了如何将outputStream转换为字节数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将OutputStream转换为字节数组?我发现首先我需要将此OutputStream转换为ByteArrayOutputStream。此OutputStream类中只有write()方法,我不知道该怎么做。有什么想法吗?
How can I convert an OutputStream to a byte array? I have found that first I need to convert this OutputStream to a ByteArrayOutputStream. There is only write() method in this OutputStream class and I don't know what to do. Is there any idea?
推荐答案
创建 ByteArrayOutputStream
。
通过调用 toByteArray()来获取其内容
这篇关于如何将outputStream转换为字节数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文