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 offset, int length) Create a read-only, seekable byte channel backed by a byte array. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
boolean
isOpen()
long
position()
position
(long newPosition) int
read
(ByteBuffer dst) long
size()
truncate
(long size) int
write
(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 offset, int length) Create a read-only, seekable byte channel backed by a byte array.- Parameters:
data
- input data to be wrappedoffset
- start offsetlength
- wrapped size
-
-
Method Details
-
isOpen
public boolean isOpen() -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
read
- Specified by:
read
in interfaceReadableByteChannel
- Specified by:
read
in interfaceSeekableByteChannel
- Throws:
IOException
-
write
- Specified by:
write
in interfaceSeekableByteChannel
- Specified by:
write
in interfaceWritableByteChannel
- Throws:
IOException
-
position
- Specified by:
position
in interfaceSeekableByteChannel
- Throws:
IOException
-
position
- Specified by:
position
in interfaceSeekableByteChannel
- Throws:
IOException
-
size
- Specified by:
size
in interfaceSeekableByteChannel
- Throws:
IOException
-
truncate
- Specified by:
truncate
in interfaceSeekableByteChannel
- Throws:
IOException
-