How to convert byte[] to InputStream?

152,053

Solution 1

ByteArrayInputStream extends InputStream:

InputStream myInputStream = new ByteArrayInputStream(myBytes); 

Solution 2

Should be easy to find in the javadocs...

byte[] byteArr = new byte[] { 0xC, 0xA, 0xF, 0xE };
InputStream is = new ByteArrayInputStream(byteArr);

Solution 3

ByteArrayInputStream

Solution 4

Theres the ByteArrayInputStream.

It does exactly this.

Solution 5

Check out java.io.ByteArrayInputStream

Share:
152,053
Renato Dinhani
Author by

Renato Dinhani

Solving real problems.

Updated on July 05, 2022

Comments