Java ByteBuffer to Stream toStream(ByteBuffer byteBuffer)

Here you can find the source of toStream(ByteBuffer byteBuffer)

Description

to Stream

License

Apache License

Declaration

public static InputStream toStream(ByteBuffer byteBuffer) 

Method Source Code


//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);
    }
}

Related

  1. toStream(ByteBuffer byteBuffer)