convert ByteArrayOutputStream to FileInputStream

java

Solution

You can create a `ByteArrayInputStream` with

InputStream is = new ByteArrayInputStream(bos.toByteArray());

and then read from this `InputStream`.

If your interface only accepts a `FileInputStream` then the interface is broken...

If, at all, an interface only works with files it should accept a `File` else it should use an `InputStream`.

Also if you use threads you can use `PipedInputStream` and `PipedOutputStream` directly between the threads.

Problem

I have stream saved in `ByteArrayOutputStream`. now I want to to read that in `FileInputStream`. how Can I do that? it's my outputStream. ``` ... OutputStream out = new ByteArrayOutputStream(); ... ``` now how to read that, from `FileInputStream`?

Original source

Related problems