Package com.pnfsoftware.jeb.util.io
Class ArraySeekableByteChannel
java.lang.Object
com.pnfsoftware.jeb.util.io.ArraySeekableByteChannel
- All Implemented Interfaces:
Closeable,AutoCloseable,ByteChannel,Channel,ReadableByteChannel,SeekableByteChannel,WritableByteChannel
Read-only, seekable, byte-array backed channel.
-
Constructor Summary
ConstructorsConstructorDescriptionArraySeekableByteChannel(byte[] data) Create a read-only, seekable byte channel backed by a byte array.ArraySeekableByteChannel(byte[] data, int arrayBaseOffset, int size) Create a read-only, seekable byte channel backed by a byte array. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanisOpen()longposition()position(long newPosition) intread(ByteBuffer dst) Note that this implementation reads all the bytes it can read, up to the requested amount, which means there is no need for aread()loop.longsize()truncate(long size) intwrite(ByteBuffer src)
-
Constructor Details
-
ArraySeekableByteChannel
public ArraySeekableByteChannel(byte[] data) Create a read-only, seekable byte channel backed by a byte array.- Parameters:
data- input data to be wrapped
-
ArraySeekableByteChannel
public ArraySeekableByteChannel(byte[] data, int arrayBaseOffset, int size) Create a read-only, seekable byte channel backed by a byte array.- Parameters:
data- input data to be wrappedarrayBaseOffset- base offset which will be associated to position 0 in the channelsize- available size from the base offset
-
-
Method Details
-
isOpen
public boolean isOpen() -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Throws:
IOException
-
read
Note that this implementation reads all the bytes it can read, up to the requested amount, which means there is no need for aread()loop.- Specified by:
readin interfaceReadableByteChannel- Specified by:
readin interfaceSeekableByteChannel- Throws:
IOException
-
write
- Specified by:
writein interfaceSeekableByteChannel- Specified by:
writein interfaceWritableByteChannel- Throws:
IOException
-
position
- Specified by:
positionin interfaceSeekableByteChannel- Throws:
IOException
-
position
- Specified by:
positionin interfaceSeekableByteChannel- Throws:
IOException
-
size
- Specified by:
sizein interfaceSeekableByteChannel- Throws:
IOException
-
truncate
- Specified by:
truncatein interfaceSeekableByteChannel- Throws:
IOException
-