Package com.celer
Class COMOutputStream
java.lang.Object
java.io.OutputStream
com.celer.COMOutputStream
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class COMOutputStream
extends java.io.OutputStream
-
Method Summary
Modifier and Type Method Description void
write(byte[] buf)
Writesbuf.length
bytes from the specified byte array to the COM port.void
write(byte[] buf, int off, int len)
Writeslen
bytes from the specified byte array starting at offsetoff
to the COM port.void
write(int bb)
Writes the specified byte to the COM port.
-
Method Details
-
write
public final void write(int bb) throws java.io.IOExceptionWrites the specified byte to the COM port. The general contract forwrite
is that one byte is written to the COM port. The byte to be written is the eight low-order bits of the argumentbb
. The 24 high-order bits ofbb
are ignored.- Specified by:
write
in classjava.io.OutputStream
- Parameters:
bb
- Thebyte
.- Throws:
java.io.IOException
- if an I/O error occurs. In particular, a device disconnection can trigger this error.
-
write
public final void write(byte[] buf) throws java.io.IOExceptionWritesbuf.length
bytes from the specified byte array to the COM port. The general contract forwrite(buf)
is that it should have exactly the same effect as the callwrite(buf, 0, buf.length)
.- Overrides:
write
in classjava.io.OutputStream
- Parameters:
buf
- The byte array containing the data to be written.- Throws:
java.io.IOException
- if an I/O error occurs. In particular, a device disconnection can trigger this error.
-
write
public final void write(byte[] buf, int off, int len) throws java.io.IOExceptionWriteslen
bytes from the specified byte array starting at offsetoff
to the COM port. The general contract forwrite(buf, off, len)
is that some of the bytes in the arraybuf
are written to the COM port in order. Elementbuf[off]
is the first byte written andbuf[off + len - 1]
is the last byte written.- Overrides:
write
in classjava.io.OutputStream
- Parameters:
buf
- The byte array containing the data to be written.off
- The start offset in the data.len
- The number of bytes to write.- Throws:
java.io.IOException
- if an I/O error occurs. In particular, a device disconnection can trigger this error.java.lang.NullPointerException
- ifbuf
isnull
java.lang.IndexOutOfBoundsException
- ifoff
is negative,len
is negative, orlen
is greater thanbuf.length - off
-