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 voidclose()protected static intcopy(ByteBuffer _source, byte[] _destiny, int _from, int _to)booleanisOpen()longposition()SeekableByteChannelposition(long _newPosition)intread(ByteBuffer _destiny)longsize()SeekableByteChanneltruncate(long _size)intwrite(ByteBuffer _source)
-
-
-
Constructor Detail
-
MemorySeekableByteChannel
public MemorySeekableByteChannel()
-
MemorySeekableByteChannel
public MemorySeekableByteChannel(InputStream _inputStream)
-
-
Method Detail
-
position
public long position() throws IOException- Specified by:
positionin interfaceSeekableByteChannel- Throws:
IOException
-
position
public SeekableByteChannel position(long _newPosition) throws IOException
- Specified by:
positionin interfaceSeekableByteChannel- Throws:
IOException
-
read
public int read(ByteBuffer _destiny) throws IOException
- Specified by:
readin interfaceReadableByteChannel- Specified by:
readin 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:
writein interfaceSeekableByteChannel- Specified by:
writein interfaceWritableByteChannel- Throws:
IOException
-
truncate
public SeekableByteChannel truncate(long _size) throws IOException
- Specified by:
truncatein interfaceSeekableByteChannel- Throws:
IOException
-
size
public long size() throws IOException- Specified by:
sizein interfaceSeekableByteChannel- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-