Package org.bytemechanics.commons.io
Class MemorySeekableByteChannel
- java.lang.Object
-
- org.bytemechanics.commons.io.MemorySeekableByteChannel
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ByteChannel
,Channel
,ReadableByteChannel
,SeekableByteChannel
,WritableByteChannel
public class MemorySeekableByteChannel extends Object implements SeekableByteChannel
Creates a seekable byte channel stored in memory- Since:
- 1.8.0
- Author:
- afarre
-
-
Constructor Summary
Constructors Constructor Description MemorySeekableByteChannel()
MemorySeekableByteChannel(InputStream _inputStream)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
protected static int
copy(ByteBuffer _source, byte[] _destiny, int _from, int _to)
boolean
isOpen()
long
position()
SeekableByteChannel
position(long _newPosition)
int
read(ByteBuffer _destiny)
long
size()
SeekableByteChannel
truncate(long _size)
int
write(ByteBuffer _source)
-
-
-
Constructor Detail
-
MemorySeekableByteChannel
public MemorySeekableByteChannel()
-
MemorySeekableByteChannel
public MemorySeekableByteChannel(InputStream _inputStream)
-
-
Method Detail
-
position
public long position() throws IOException
- Specified by:
position
in interfaceSeekableByteChannel
- Throws:
IOException
-
position
public SeekableByteChannel position(long _newPosition) throws IOException
- Specified by:
position
in interfaceSeekableByteChannel
- Throws:
IOException
-
read
public int read(ByteBuffer _destiny) throws IOException
- Specified by:
read
in interfaceReadableByteChannel
- Specified by:
read
in interfaceSeekableByteChannel
- Throws:
IOException
-
copy
protected static final int copy(ByteBuffer _source, byte[] _destiny, int _from, int _to)
-
write
public int write(ByteBuffer _source) throws IOException
- Specified by:
write
in interfaceSeekableByteChannel
- Specified by:
write
in interfaceWritableByteChannel
- Throws:
IOException
-
truncate
public SeekableByteChannel truncate(long _size) throws IOException
- Specified by:
truncate
in interfaceSeekableByteChannel
- Throws:
IOException
-
size
public long size() throws IOException
- Specified by:
size
in interfaceSeekableByteChannel
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-