Sun SPOT API
Green Release  


com.sun.spot.io.j2me.memory
Class MemoryInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.sun.spot.io.j2me.memory.MemoryInputStream

public class MemoryInputStream
extends InputStream

An InputStream that streams over the device memory. You should not normally construct instance of this class directly, but instead, use the GCF framework. See Protocol for more details.


Constructor Summary
MemoryInputStream(int startAddress)
          Construct an instance to read from a given memory address.
 
Method Summary
 int available()
          Returns the number of bytes available to be read from the 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.
 long skip(long x)
          Skips over and discards n bytes of data from this input stream.
 
Methods inherited from class java.io.InputStream
mark, markSupported, read, read, reset
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryInputStream

public MemoryInputStream(int startAddress)
Construct an instance to read from a given memory address.

Parameters:
startAddress - -- the memory address at which to start reading
Method Detail

read

public int read()
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.

close

public void close()
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

skip

public long skip(long x)
Description copied from class: InputStream
Skips over and discards n bytes of data from this input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. The actual number of bytes skipped is returned. If n is negative, no bytes are skipped.

The skip method of InputStream creates a byte array and then repeatedly reads into it until n bytes have been read or the end of the stream has been reached. Subclasses are encouraged to provide a more efficient implementation of this method.

Overrides:
skip in class InputStream
Parameters:
x - the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.

available

public int available()
Returns the number of bytes available to be read from the stream.

Overrides:
available in class InputStream
Returns:
always returns 1 since the stream never blocks and we don't know its size

Sun SPOT API
Green Release  


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