Here you can find the source of toStream(ByteBuffer byteBuffer)
public static InputStream toStream(ByteBuffer byteBuffer)
//package com.java2s; //License from project: Apache License import java.io.ByteArrayInputStream; import java.io.InputStream; import java.nio.ByteBuffer; public class Main { public static InputStream toStream(ByteBuffer byteBuffer) { byte[] bytes = new byte[byteBuffer.remaining()]; byteBuffer.get(bytes);/*from w w w . j a v a 2 s .co m*/ return new ByteArrayInputStream(bytes); } }