josx.rcxcomm
Class RCXInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byjosx.rcxcomm.RCXInputStream

public class RCXInputStream
extends InputStream

RCXInputStream provides an interface similar to FileInputStream. It is a cut down version of RCXPort, which provides just read access. Adapted from original code created by the LEGO3 Team at DTU-IAU


Field Summary
static int DEFAULT_BUFFER_SIZE
          The default buffer size for the InputStream is 32 bytes
static int DEFAULT_TIMEOUT
           
 
Constructor Summary
RCXInputStream()
          Creates new RCXInputStream
 
Method Summary
 int available()
          Checks if there is any data avaliable on the InputStream
 void close()
          Close the stream and stop listening
 int read()
          Read a single byte from the InputStream.
 void setTimeOut(int timeout)
          Setter for timeout
 
Methods inherited from class java.io.InputStream
mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait
 

Field Detail

DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE
The default buffer size for the InputStream is 32 bytes

See Also:
Constant Field Values

DEFAULT_TIMEOUT

public static final int DEFAULT_TIMEOUT
See Also:
Constant Field Values
Constructor Detail

RCXInputStream

public RCXInputStream()
Creates new RCXInputStream

Method Detail

setTimeOut

public void setTimeOut(int timeout)
Setter for timeout

Parameters:
timeout - the timeout

available

public int available()
              throws IOException
Checks if there is any data avaliable on the InputStream

Overrides:
available in class InputStream
Returns:
The number of bytes avaliable on the InputStream
Throws:
IOException - is never thrown

read

public int read()
         throws IOException
Read a single byte from the InputStream. Returns value as an int value between 0 and 255.

Specified by:
read in class InputStream
Returns:
A data byte from the stream
Throws:
IOException - is thrown when the read is timed out

close

public void close()
Close the stream and stop listening

Overrides:
close in class InputStream