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()
Get an input stream for the resource content.
|
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 - The buffer into which bytes are to be transferredIOExceptionSeekableByteChannel.read(java.nio.ByteBuffer)public int write(ByteBuffer src) throws IOException
write in interface SeekableByteChannelwrite in interface WritableByteChannelsrc - The buffer from which bytes are to be writtenIOExceptionSeekableByteChannel.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)
truncate in interface SeekableByteChannelsize - SeekableByteChannel.truncate(long)public InputStream openStream()
openStream in interface AssetInputStream for each callAsset.openStream()Copyright © 2024 JBoss by Red Hat. All rights reserved.