Why would you want to do that? A ByteArrayInputStream doesn't seem to have any methods that any other InputStream doesn't have. It just has the additional ability (or restriction in this case) that it reads input from an existing byte array. Which means you would need to create the byte array first, since it doesn't exist initially. Why bother? I mean, you can do it:
But isn't this easier?
The only advantage I see to the former method is that a ByteArrayInputStream will never block, and will always be able to read all bytes you ask for up to the end of the byte array. This may be useful or necessary for some applications. If not though, I'd keep things simple where possible, and just use the BufferedInputStream technique.
"I'm not back." - Bill Harding, Twister
subject: Convert java.io.File to ByteArryInputStream?