Java - 连接两个输出流
是否可以连接两个 OutputStream(相同类型,存储为 OutputStream)而不将其中任何一个转换为字符串?如果是这样,怎么办?
Is it possible to concatenate two OutputStreams (of the same type, stored as OutputStreams) without converting either to a string? If so, how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因此,如果您有 OutputStream A 和 OutputStream B,并且您想将它们连接起来,以便最终得到 A 中的内容,然后是 B 中的内容,您可以将 B 转换为 InputStream (这项任务可能已被在这个论坛中解释了超过9000次),然后从这个新的InputStream中读取数据,并将其写入A。那里:一个通用问题的通用答案。祝你好运!
So, If you have OutputStream A, and OutputStream B, and you want to concatenate them so that you end up with the stuff from A, followed by the stuff from B, you could convert B into an InputStream (a task that has likely been explained over 9000 times in this forum), and then Read data from this new InputStream, and write it to A. There: A generic answer for a generic question. Good luck!
一个简短的例子:
A short example: