Returns an input stream for a ByteBuffer. - Java java.nio

Java examples for java.nio:ByteBuffer Stream

Description

Returns an input stream for a ByteBuffer.

Demo Code


import java.io.*;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;

public class Main{
    /**/*from www .ja  v  a 2  s .c o m*/
     * Returns an input stream for a ByteBuffer.
     * The read() methods use the relative ByteBuffer get() methods.
     */
    public static InputStream newInputStream(final ByteBuffer buf) {
        return new BufferInputStream(buf);
    }
}

Related Tutorials