Class SeekableInMemoryByteChannel
- java.lang.Object
-
- org.jboss.shrinkwrap.api.nio.file.SeekableInMemoryByteChannel
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ByteChannel
,Channel
,ReadableByteChannel
,SeekableByteChannel
,WritableByteChannel
public class SeekableInMemoryByteChannel extends Object implements SeekableByteChannel
SeekableByteChannel
implementation backed by an auto-resizing byte array; thread-safe. Can hold a maxiumum ofInteger.MAX_VALUE
bytes.- Author:
- Andrew Lee Rubinger
-
-
Constructor Summary
Constructors Constructor Description SeekableInMemoryByteChannel()
Creates a new instance with 0 size and 0 position, and open.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
boolean
isOpen()
long
position()
SeekableByteChannel
position(long newPosition)
int
read(ByteBuffer destination)
long
size()
SeekableByteChannel
truncate(long size)
int
write(ByteBuffer source)
-
-
-
Method Detail
-
isOpen
public boolean isOpen()
- Specified by:
isOpen
in interfaceChannel
- See Also:
Channel.isOpen()
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- See Also:
Channel.close()
-
read
public int read(ByteBuffer destination) throws IOException
- Specified by:
read
in interfaceReadableByteChannel
- Specified by:
read
in interfaceSeekableByteChannel
- Throws:
IOException
- See Also:
SeekableByteChannel.read(java.nio.ByteBuffer)
-
write
public int write(ByteBuffer source) throws IOException
- Specified by:
write
in interfaceSeekableByteChannel
- Specified by:
write
in interfaceWritableByteChannel
- Throws:
IOException
- See Also:
SeekableByteChannel.write(java.nio.ByteBuffer)
-
position
public long position() throws IOException
- Specified by:
position
in interfaceSeekableByteChannel
- Throws:
IOException
- See Also:
SeekableByteChannel.position()
-
position
public SeekableByteChannel position(long newPosition) throws IOException
- Specified by:
position
in interfaceSeekableByteChannel
- Throws:
IOException
- See Also:
SeekableByteChannel.position(long)
-
size
public long size() throws IOException
- Specified by:
size
in interfaceSeekableByteChannel
- Throws:
IOException
- See Also:
SeekableByteChannel.size()
-
truncate
public SeekableByteChannel truncate(long size) throws IOException
- Specified by:
truncate
in interfaceSeekableByteChannel
- Throws:
IOException
- See Also:
SeekableByteChannel.truncate(long)
-
-