public class ByteArrayReadableChannel
extends java.lang.Object
implements java.nio.channels.ReadableByteChannel
ReadableByteChannel implementation which reads
from a backing array.
This is an NIO variant of ByteArrayInputStream.
Created by covers1624 on 11/1/24.
| Constructor and Description |
|---|
ByteArrayReadableChannel(byte[] buf)
Create a new channel from the given buffer.
|
ByteArrayReadableChannel(byte[] buf,
int off,
int end)
Create a new channel from part of the given buffer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
boolean |
isOpen() |
int |
read(java.nio.ByteBuffer dst) |
public ByteArrayReadableChannel(byte[] buf)
The entire buffer will be read.
buf - The buffer.public ByteArrayReadableChannel(byte[] buf,
int off,
int end)
The buffer will start reading at pos
and stop reading at end;
buf - The buffer.off - The start index (inclusive).end - The end index (exclusive).public int read(java.nio.ByteBuffer dst)
throws java.io.IOException
read in interface java.nio.channels.ReadableByteChanneljava.io.IOExceptionpublic boolean isOpen()
isOpen in interface java.nio.channels.Channelpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface java.nio.channels.Channeljava.io.IOException