public class MemoryAsset extends java.lang.Object implements Asset, java.nio.channels.SeekableByteChannel
| Modifier and Type | Field and Description |
|---|---|
private SeekableInMemoryByteChannel |
delegate |
| Constructor and Description |
|---|
MemoryAsset()
Creates a new instance with internal memory buffer initially sized at 0 and at position 0, capable of holding a
maximum of
Integer.MAX_VALUE bytes. |
MemoryAsset(SeekableInMemoryByteChannel delegate)
Creates a new instance with internal memory buffer delegate using the specified (required)
SeekableInMemoryByteChannel |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
boolean |
isOpen() |
java.io.InputStream |
openStream()
Get a input stream for the resource content.
|
long |
position() |
java.nio.channels.SeekableByteChannel |
position(long newPosition) |
int |
read(java.nio.ByteBuffer dst) |
long |
size() |
java.nio.channels.SeekableByteChannel |
truncate(long size) |
int |
write(java.nio.ByteBuffer src) |
private final SeekableInMemoryByteChannel delegate
public MemoryAsset()
Integer.MAX_VALUE bytes.MemoryAsset(SeekableInMemoryByteChannel delegate) throws java.lang.IllegalArgumentException
SeekableInMemoryByteChanneldelegate - java.lang.IllegalArgumentExceptionpublic boolean isOpen()
isOpen in interface java.nio.channels.ChannelChannel.isOpen()public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface java.nio.channels.Channeljava.io.IOExceptionChannel.close()public int read(java.nio.ByteBuffer dst)
throws java.io.IOException
read in interface java.nio.channels.ReadableByteChannelread in interface java.nio.channels.SeekableByteChanneldst - java.io.IOExceptionSeekableByteChannel.read(java.nio.ByteBuffer)public int write(java.nio.ByteBuffer src)
throws java.io.IOException
write in interface java.nio.channels.SeekableByteChannelwrite in interface java.nio.channels.WritableByteChannelsrc - java.io.IOExceptionSeekableByteChannel.write(java.nio.ByteBuffer)public long position()
throws java.io.IOException
position in interface java.nio.channels.SeekableByteChanneljava.io.IOExceptionSeekableByteChannel.position()public java.nio.channels.SeekableByteChannel position(long newPosition)
throws java.io.IOException
position in interface java.nio.channels.SeekableByteChannelnewPosition - java.io.IOExceptionSeekableByteChannel.position(long)public long size()
throws java.io.IOException
size in interface java.nio.channels.SeekableByteChanneljava.io.IOExceptionSeekableByteChannel.size()public java.nio.channels.SeekableByteChannel truncate(long size)
throws java.io.IOException
truncate in interface java.nio.channels.SeekableByteChannelsize - java.io.IOExceptionSeekableByteChannel.truncate(long)public java.io.InputStream openStream()
openStream in interface AssetInputStream for each callAsset.openStream()