public class AssociationOutputStream
extends java.io.OutputStream
A specialized java.io.OutputStream which buffers and fragments
data which is written to it into PDUs and sends them over
the supplied OutputStream which is (presumably) that of the java.net.Socket
of an established Association
.
This stream buffers data that is written to it and when it is either flushed or closed or reaches the specified maximum PDU size, writes data (not command) PDU's to the supplied output stream.
Need to take care with "last fragment" flag ... that cannot be set until close() is called, and if the buffer is empty at that time, a zero length PDU will be sent.
Constructor and Description |
---|
AssociationOutputStream(java.io.OutputStream out,
int maxPDUSize,
int presentationContextID)
Construct a PDU buffering OutputStream on top of another OutputStream
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Sets the last fragment flag and flushes (which sends a zero
length PDU if necessary, and pads to an even length, if necessary).
|
void |
flush()
Do nothing.
|
void |
write(byte[] b)
Buffer the supplied data, flushing (actually sending) PDUs
when the buffer is filled.
|
void |
write(byte[] b,
int off,
int len)
Buffer the supplied data, flushing (actually sending) PDUs
when the buffer is filled.
|
void |
write(int i)
Buffer the supplied data, flushing (actually sending) PDUs
when the buffer is filled.
|
public AssociationOutputStream(java.io.OutputStream out, int maxPDUSize, int presentationContextID) throws DicomNetworkException
out
- where to send the buffered outputmaxPDUSize
- how large to make the buffer (i.e. the PDU) sizepresentationContextID
- included in the header of each PDUDicomNetworkException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.OutputStream
java.io.IOException
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
java.io.IOException
public void write(byte[] b) throws java.io.IOException
write
in class java.io.OutputStream
b
- java.io.IOException
public void write(byte[] b, int off, int len) throws java.io.IOException
write
in class java.io.OutputStream
b
- off
- len
- java.io.IOException
public void write(int i) throws java.io.IOException
write
in class java.io.OutputStream
i
- java.io.IOException