public final class SerialComOutByteStream extends OutputStream
Represents an output stream of bytes that gets sent over to serial port for transmission.
| Constructor and Description |
|---|
SerialComOutByteStream(SerialComManager scm,
SerialComPortHandleInfo portHandleInfo,
long handle,
SerialComManager.SMODE streamMode)
Allocates a new SerialComOutByteStream object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
This method releases the OutputStream object internally associated with the operating handle.
|
void |
flush()
SCM always flushes data every time writeBytes() method is called.
|
void |
write(byte[] data)
Writes data.length bytes from the specified byte array to this output stream.
|
void |
write(byte[] data,
int off,
int len)
Writes len bytes from the specified byte array starting at offset off to this output stream.
|
void |
write(int data)
Writes the specified byte to this output stream (eight low-order bits of the argument data).
|
public SerialComOutByteStream(SerialComManager scm, SerialComPortHandleInfo portHandleInfo, long handle, SerialComManager.SMODE streamMode) throws SerialComException
Allocates a new SerialComOutByteStream object.
scm - instance of SerialComManager class with which this stream will associate itself.handle - handle of the serial port on which to write data bytes.streamMode - indicates blocking or non-blocking behavior of stream.SerialComException - if serial port can not be configured for specified write behavior.public void write(int data)
throws IOException
Writes the specified byte to this output stream (eight low-order bits of the argument data). The 24 high-order bits of data are ignored.
write in class OutputStreamdata - integer to be written to serial port.IOException - if write fails or output stream has been closed.public void write(byte[] data)
throws IOException
Writes data.length bytes from the specified byte array to this output stream.
write in class OutputStreamdata - byte type array of data to be written to serial port.IOException - if write fails or output stream has been closed.NullPointerException - if data is null.IllegalArgumentException - if data is not a byte type array.public void write(byte[] data,
int off,
int len)
throws IOException,
IndexOutOfBoundsException
Writes len bytes from the specified byte array starting at offset off to this output stream.
If b is null, a NullPointerException is thrown.
If off is negative, or len is negative, or off+len is greater than the length of the array data, then an IndexOutOfBoundsException is thrown.
write in class OutputStreamdata - byte type array of data to be written to serial port.off - offset from where to start sending data.len - length of data to be written.IOException - if write fails or output stream has been closed.IllegalArgumentException - if data is not a byte type array.NullPointerException - if data is null.IndexOutOfBoundsException - If off is negative, or len is negative, or off+len is greater
than the length of the array data.public void flush()
throws IOException
SCM always flushes data every time writeBytes() method is called. So do nothing just return.
flush in interface Flushableflush in class OutputStreamIOException - if write fails or output stream has been closed.public void close()
throws IOException
This method releases the OutputStream object internally associated with the operating handle.
To actually close the port closeComPort() method should be used.
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOException - if write fails or output stream has been closed.Copyright © 2016. All rights reserved.