public class Stream
extends java.lang.Object
implements java.nio.channels.ByteChannel
It implements the ByteChannel interface.
Basic usage:
ByteBuffer buf = ByteBuffer.allocate(1024);
Stream str = conn.streamNew(0);
... // open the stream e.g. calling Domain.screenshot
while (str.read(buf) != -1) {
buf.flip();
... // do something with the data
buf.compact();
}
If you want to use this class as an InputStream or OutputStream,
convert it using the Channels.newInputStream and Channels.newOutputStream respectively.
| Modifier and Type | Field and Description |
|---|---|
static int |
VIR_STREAM_NONBLOCK |
| Modifier and Type | Method and Description |
|---|---|
int |
abort()
Request that the in progress data transfer be cancelled abnormally before
the end of the stream has been reached
|
int |
addCallback(int events,
Libvirt.VirStreamEventCallback cb)
Register a callback to be notified when a stream becomes writable, or
readable.
|
void |
close() |
protected void |
closeStream() |
protected void |
finalize() |
int |
finish()
Indicate that there is no further data is to be transmitted on the
stream.
|
int |
free()
Decrement the reference count on a stream, releasing the stream object if
the reference count has hit zero.
|
protected boolean |
isEOF() |
boolean |
isOpen() |
int |
read(java.nio.ByteBuffer buffer) |
int |
receive(byte[] data)
Receives data from the stream into the buffer provided.
|
protected int |
receive(java.nio.ByteBuffer buffer) |
int |
receiveAll(Libvirt.VirStreamSinkFunc handler)
Batch receive method
|
int |
removeCallback()
Remove an event callback from the stream
|
int |
send(byte[] data)
Write a series of bytes to the stream.
|
protected int |
send(java.nio.ByteBuffer buffer) |
int |
sendAll(Libvirt.VirStreamSourceFunc handler)
Batch send method
|
int |
updateCallback(int events)
Changes the set of events to monitor for a stream.
|
int |
write(java.nio.ByteBuffer buffer) |
public static final int VIR_STREAM_NONBLOCK
protected boolean isEOF()
public int abort()
throws LibvirtException
LibvirtExceptionpublic int addCallback(int events,
Libvirt.VirStreamEventCallback cb)
throws LibvirtException
events - the events to monitorcb - the callback methodLibvirtExceptionprotected void finalize()
throws LibvirtException
finalize in class java.lang.ObjectLibvirtExceptionpublic int finish()
throws LibvirtException
LibvirtExceptionpublic int free()
throws LibvirtException
LibvirtExceptionpublic int receive(byte[] data)
throws LibvirtException
data - buffer to put the data intoLibvirtExceptionprotected int receive(java.nio.ByteBuffer buffer)
throws LibvirtException
LibvirtExceptionpublic int read(java.nio.ByteBuffer buffer)
throws java.io.IOException
read in interface java.nio.channels.ReadableByteChanneljava.io.IOExceptionpublic int write(java.nio.ByteBuffer buffer)
throws java.io.IOException
write in interface java.nio.channels.WritableByteChanneljava.io.IOExceptionprotected void closeStream()
throws LibvirtException
LibvirtExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface java.nio.channels.Channeljava.io.IOExceptionpublic boolean isOpen()
isOpen in interface java.nio.channels.Channelpublic int receiveAll(Libvirt.VirStreamSinkFunc handler) throws LibvirtException
handler - the callback handlerLibvirtExceptionpublic int removeCallback()
throws LibvirtException
LibvirtExceptionpublic int send(byte[] data)
throws LibvirtException
data - the data to writeLibvirtExceptionprotected int send(java.nio.ByteBuffer buffer)
throws LibvirtException
LibvirtExceptionpublic int sendAll(Libvirt.VirStreamSourceFunc handler) throws LibvirtException
handler - the callback handlerLibvirtExceptionpublic int updateCallback(int events)
throws LibvirtException
events - the events to monitorLibvirtException