How to convert byte[] to InputStream?

Possible Duplicate:
Can we convert a byte array into an InputStream in Java?

There is a way to convert an array of bytes ( byte[] ) to InputStream in Java? I looked at some methods in Apache Commons IO, but found nothing.


ByteArrayInputStream扩展了InputStream

InputStream myInputStream = new ByteArrayInputStream(myBytes); 

也许你想要一个ByteArrayInputStream?


应该很容易在javadoc中找到...

byte[] byteArr = new byte[] { 0xC, 0xA, 0xF, 0xE };
InputStream is = new ByteArrayInputStream(byteArr);
链接地址: http://www.djcxy.com/p/78384.html

上一篇: 如何在结构中并行执行多个任务

下一篇: 如何将byte []转换为InputStream?