public class MemoryAsset extends Object implements Asset, SeekableByteChannel
Asset implementation backed by an internal memory representation; able to be directly added to an
Archive, and supports all operations designated by the NIO.2 SeekableByteChannel API. Thread-safe.| 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. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
boolean |
isOpen() |
InputStream |
openStream() |
long |
position() |
SeekableByteChannel |
position(long newPosition) |
int |
read(ByteBuffer dst) |
long |
size() |
SeekableByteChannel |
truncate(long size) |
int |
write(ByteBuffer src) |
public MemoryAsset()
Integer.MAX_VALUE bytes.public boolean isOpen()
isOpen in interface ChannelChannel.isOpen()public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in interface ChannelIOExceptionChannel.close()public int read(ByteBuffer dst) throws IOException
read in interface ReadableByteChannelread in interface SeekableByteChanneldst - IOExceptionSeekableByteChannel.read(java.nio.ByteBuffer)public int write(ByteBuffer src) throws IOException
write in interface SeekableByteChannelwrite in interface WritableByteChannelsrc - IOExceptionSeekableByteChannel.write(java.nio.ByteBuffer)public long position()
throws IOException
position in interface SeekableByteChannelIOExceptionSeekableByteChannel.position()public SeekableByteChannel position(long newPosition) throws IOException
position in interface SeekableByteChannelnewPosition - IOExceptionSeekableByteChannel.position(long)public long size()
throws IOException
size in interface SeekableByteChannelIOExceptionSeekableByteChannel.size()public SeekableByteChannel truncate(long size) throws IOException
truncate in interface SeekableByteChannelsize - IOExceptionSeekableByteChannel.truncate(long)public InputStream openStream()
openStream in interface AssetAsset.openStream()Copyright © 2013 JBoss by Red Hat. All Rights Reserved.