SunSPOT API V3.0


com.sun.spot.peripheral
Class BoundedInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.sun.spot.peripheral.BoundedInputStream

public class BoundedInputStream
extends InputStream

Wraps a parent InputStream with an input stream on the assumptions that the first four bytes of the parent's content are a Java int which tells us how many more valid bytes remain in the parent.


Constructor Summary
BoundedInputStream(InputStream in)
          Construct an instance based on the supplied parent InputStream.
 
Method Summary
 int available()
          Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.
 void close()
          Closes this input stream and releases any system resources associated with the stream.
 int read()
          Reads the next byte of data from the input stream.
 
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, wait
 

Constructor Detail

BoundedInputStream

public BoundedInputStream(InputStream in)
                   throws IOException
Construct an instance based on the supplied parent InputStream.

Parameters:
in - the parent input stream (see class comment)
Throws:
IOException
Method Detail

read

public int read()
         throws IOException
Description copied from class: InputStream
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.

A subclass must provide an implementation of this method.

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

close

public void close()
           throws IOException
Description copied from class: InputStream
Closes this input stream and releases any system resources associated with the stream.

The close method of InputStream does nothing.

Overrides:
close in class InputStream
Throws:
IOException - if an I/O error occurs.

available

public int available()
              throws IOException
Description copied from class: InputStream
Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream. The next caller might be the same thread or another thread.

The available method for class InputStream always returns 0.

This method should be overridden by subclasses.

Overrides:
available in class InputStream
Returns:
the number of bytes that can be read from this input stream without blocking.
Throws:
IOException - if an I/O error occurs.

SunSPOT API V3.0


Copyright © 2006, 2007 Sun Microsystems, Inc. All Rights Reserved.