org.apache.commons.launcher
Class NonBlockingInputStream
java.lang.Object
|
+--java.io.InputStream
|
+--java.io.FilterInputStream
|
+--java.io.BufferedInputStream
|
+--org.apache.commons.launcher.NonBlockingInputStream
- public class NonBlockingInputStream
- extends java.io.BufferedInputStream
A class that prevents blocking reads. This class is usually used to prevent
native blocking reads of System.in on Windows platforms since on some
Windows platforms, reading System.in will cause the entire JVM to block.
- Author:
- Patrick Luby
Fields inherited from class java.io.BufferedInputStream |
buf, count, marklimit, markpos, pos |
Fields inherited from class java.io.FilterInputStream |
in |
Constructor Summary |
NonBlockingInputStream(java.io.InputStream in)
Creates a NonBlockingInputStream by using the
BufferedInputStream as the underlying input stream. |
Method Summary |
int |
read()
Reads the next byte of data from this input stream. |
int |
read(byte[] b)
Reads some number of bytes from the input stream and stores them into the * specified buffer. |
int |
read(byte[] b,
int off,
int len)
Reads up to len bytes from the input stream and stores them
into the specified buffer. |
long |
skip(long n)
Skips over and discards n bytes of data from this input
stream. |
Methods inherited from class java.io.BufferedInputStream |
available, close, mark, markSupported, 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)
- Creates a
NonBlockingInputStream
by using the
BufferedInputStream
as the underlying input stream.
- Parameters:
in
- the underlying input stream
read
public int read()
throws java.io.IOException
- Reads the next byte of data from this input stream. This method invokes
the superclass'
BufferedInputStream.read()
method if the number
of available bytes is greater than 0.
- Overrides:
read
in class java.io.BufferedInputStream
- Returns:
- the next byte of data, or -1 if the end of the stream is reached
- Throws:
IOExeption
- if an I/O error occurs
read
public int read(byte[] b)
throws java.io.IOException
- Reads some number of bytes from the input stream and stores them into the * specified buffer. This method invokes the superclass'
FilterInputStream.read(byte[])
method if the number of
available bytes is greater than 0.
- Overrides:
read
in class java.io.FilterInputStream
- Parameters:
b
- the buffer into which the data is read- Returns:
- the total number of bytes read into the buffer, or -1 if the end
of the stream is reached
- Throws:
IOExeption
- if an I/O error occurs
read
public int read(byte[] b,
int off,
int len)
throws java.io.IOException
- Reads up to
len
bytes from the input stream and stores them
into the specified buffer. This method invokes the superclass'
BufferedInputStream.read(byte[], int, int)
method if the number
of available bytes is greater than 0.
- Overrides:
read
in class java.io.BufferedInputStream
- Parameters:
b
- the buffer into which the data is readoff
- the start offset in array b at which the data is writtenlen
- the maximum number of bytes to read- Returns:
- the total number of bytes read into the buffer, or -1 if the end
of the stream is reached
- Throws:
IOExeption
- if an I/O error occurs
skip
public long skip(long n)
throws java.io.IOException
- Skips over and discards
n
bytes of data from this input
stream. This method invokes the superclass'
BufferedInputStream.skip(long)
method if the number of
available bytes is greater than 0.
- Overrides:
skip
in class java.io.BufferedInputStream
- Parameters:
n
- the number of bytes to be skipped- Returns:
- the actual number of bytes skipped
- Throws:
IOExeption
- if an I/O error occurs
Copyright (c) 2001-2002 - Apache Software Foundation