com.purpletech.io
Class NonBlockingInputStream
java.lang.Object
|
+--java.io.InputStream
|
+--java.io.FilterInputStream
|
+--com.purpletech.io.NonBlockingInputStream
- public class NonBlockingInputStream
- extends java.io.FilterInputStream
clever
| Fields inherited from class java.io.FilterInputStream |
in |
|
Method Summary |
static void |
main(java.lang.String[] args)
|
int |
read()
Reads the next byte of data from this buffered input stream. |
int |
read(byte[] b,
int off,
int len)
Reads bytes into a portion of an array. |
long |
skip(long n)
Skips over and discards n bytes of data from the
input stream. |
| Methods inherited from class java.io.FilterInputStream |
available, close, mark, markSupported, read, reset |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NonBlockingInputStream
public NonBlockingInputStream(java.io.InputStream in)
- Parameters:
in - the underlying input stream.
read
public int read()
throws java.io.IOException
- Reads the next byte of data from this buffered 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.
The read method of
NonBlockingInputStream returns the next byte of
data from its stream if the byte is available. If the byte is
not available -- that is, if the read() call would normally
block -- the method throws a NoDataAvailableException.
- Overrides:
read in class java.io.FilterInputStream
- 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.
NoDataAvailableException - if the call would otherwise block
read
public int read(byte[] b,
int off,
int len)
throws java.io.IOException
- Reads bytes into a portion of an array. This method will not
block. If there are no bytes available, the method throws a
NoDataAvailableException
- Overrides:
read in class java.io.FilterInputStream
- Parameters:
b - destination buffer.off - offset at which to start storing bytes.len - maximum number of bytes to read.
- Returns:
- the number of bytes read, or
-1 if the end of
the stream has been reached.
- Throws:
java.io.IOException - if an I/O error occurs.
NoDataAvailableException - if the call would otherwise block
skip
public long skip(long n)
throws java.io.IOException
- Skips over and discards
n bytes of data from the
input stream. The skip method may, for a variety of
reasons, end up skipping over some smaller number of bytes,
isibly zero. The actual number of bytes skipped is returned.
- Overrides:
skip in class java.io.FilterInputStream
- Parameters:
n - the number of bytes to be skipped.
- Returns:
- the actual number of bytes skipped.
- Throws:
java.io.IOException - if an I/O error occurs.- Since:
- JDK1.0
main
public static void main(java.lang.String[] args)