Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.ka2ddo.yaac.io
Class CloseableWhileReadingSerialInputStream

    java.lang.Object
      java.io.InputStream
          org.ka2ddo.yaac.io.CloseableWhileReadingSerialInputStream

All Implemented Interfaces:
  gnu.io.SerialPortEventListener, java.io.Closeable, java.util.EventListener

    public class CloseableWhileReadingSerialInputStream

extends java.io.InputStream
implements gnu.io.SerialPortEventListener

This class is a wrapper around a RXTX SerialPort's SerialInputStream, so that the SerialPort can be closed while a blocking read is outstanding and properly abort the read.

Constructor Summary
`CloseableWhileReadingSerialInputStream(gnu.io.SerialPort serialPort)`

Method Summary
`int` | `available()` Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.
`void` | `close()` Closes this input stream and releases any system resources associated with the stream.
`boolean` | `markSupported()` Tests if this input stream supports the `mark` and `reset` methods.
`int` | `read()` Reads the next byte of data from the input stream.
`void` | `serialEvent(gnu.io.SerialPortEvent ev)`

Methods inherited from class java.io.InputStream
`mark, read, read, reset, skip`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### CloseableWhileReadingSerialInputStream

    public CloseableWhileReadingSerialInputStream(gnu.io.SerialPort serialPort)
                                           throws java.io.IOException,
                                                  java.util.TooManyListenersException

Throws:
  `java.io.IOException`
  `java.util.TooManyListenersException`

Method Detail

### read

    public int read()
             throws java.io.IOException

  Reads the next byte of data from the input stream. The value byte is returned as an `int` in the range `0` to `255`. If no byte is available because the end of the stream has been reached, the value `-1` is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

  Specified by:
    `read` in class `java.io.InputStream`
  Returns:
    the next byte of data, or `-1` if the end of the stream is reached.
  Throws:
    `java.io.IOException` - if an I/O error occurs.

### close

    public void close()
               throws java.io.IOException

  Closes this input stream and releases any system resources associated with the stream.

  Specified by:
    `close` in interface `java.io.Closeable`
  Overrides:
    `close` in class `java.io.InputStream`
  Throws:
    `java.io.IOException` - if an I/O error occurs.

### available

    public int available()
                  throws java.io.IOException

  Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream. The next invocation might be the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

  Overrides:
    `available` in class `java.io.InputStream`
  Returns:
    an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking or `0` when it reaches the end of the input stream.
  Throws:
    `java.io.IOException` - if an I/O error occurs.

### markSupported

    public boolean markSupported()

  Tests if this input stream supports the `mark` and `reset` methods. Whether or not `mark` and `reset` are supported is an invariant property of a particular input stream instance. The `markSupported` method returns `false`.

  Overrides:
    `markSupported` in class `java.io.InputStream`
  Returns:
    `true` if this stream instance supports the mark and reset methods; `false` otherwise.
  See Also:
    `InputStream.mark(int)`, `InputStream.reset()`

### serialEvent

    public void serialEvent(gnu.io.SerialPortEvent ev)

  Specified by:
    `serialEvent` in interface `gnu.io.SerialPortEventListener`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD