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 a 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 Channel
Channel.isOpen()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in interface Channel
IOException
Channel.close()
public int read(ByteBuffer dst) throws IOException
read
in interface ReadableByteChannel
read
in interface SeekableByteChannel
dst
- IOException
SeekableByteChannel.read(java.nio.ByteBuffer)
public int write(ByteBuffer src) throws IOException
write
in interface SeekableByteChannel
write
in interface WritableByteChannel
src
- IOException
SeekableByteChannel.write(java.nio.ByteBuffer)
public long position() throws IOException
position
in interface SeekableByteChannel
IOException
SeekableByteChannel.position()
public SeekableByteChannel position(long newPosition) throws IOException
position
in interface SeekableByteChannel
newPosition
- IOException
SeekableByteChannel.position(long)
public long size() throws IOException
size
in interface SeekableByteChannel
IOException
SeekableByteChannel.size()
public SeekableByteChannel truncate(long size) throws IOException
truncate
in interface SeekableByteChannel
size
- IOException
SeekableByteChannel.truncate(long)
public InputStream openStream()
openStream
in interface Asset
InputStream
for each callAsset.openStream()
Copyright © 2016 JBoss by Red Hat. All rights reserved.