Package ej.wasi.io
Class NonBlockingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- ej.wasi.io.NonBlockingInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class NonBlockingInputStream extends FilterInputStream
Non blocking input stream
-
-
Field Summary
-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description NonBlockingInputStream(InputStream in)Creates a newNonBlockingInputStream(InputStream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intread()Reads the next byte of data from this input stream.intread(byte[] b, int off, int len)Reads up tolenbytes of data from this input stream into an array of bytes.-
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
-
-
-
-
Constructor Detail
-
NonBlockingInputStream
public NonBlockingInputStream(InputStream in)
Creates a newNonBlockingInputStream(InputStream)- Parameters:
in- the underlying input stream to to be used to read data.
-
-
Method Detail
-
read
public int read(@Nullable byte[] b, int off, int len) throws IOException
Description copied from class:FilterInputStreamReads up tolenbytes of data from this input stream into an array of bytes. Iflenis not zero, the method blocks until some input is available; otherwise, no bytes are read and0is returned.This method simply performs
in.read(b, off, len)and returns the result.- Overrides:
readin classFilterInputStream- Parameters:
b- the buffer into which the data is read.off- the start offset in the destination arrayblen- the maximum number of bytes read.- Returns:
- the total number of bytes read into the buffer, or
-1if there is no more data because the end of the stream has been reached. - Throws:
IOException- if an I/O error occurs.- See Also:
FilterInputStream.in
-
read
public int read() throws IOExceptionDescription copied from class:FilterInputStreamReads the next byte of data from this input stream. The value byte is returned as anintin the range0to255. If no byte is available because the end of the stream has been reached, the value-1is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.This method simply performs
in.read()and returns the result.- Overrides:
readin classFilterInputStream- Returns:
- the next byte of data, or
-1if the end of the stream is reached. - Throws:
IOException- if an I/O error occurs.- See Also:
FilterInputStream.in
-
-