Package org.apache.axis.transport.http
Class NonBlockingBufferedInputStream
java.lang.Object
java.io.InputStream
org.apache.axis.transport.http.NonBlockingBufferedInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintreturn the number of bytes available to be read without blockingvoidclose()disassociate from the underlying input streamintpeek()Just like read except byte is not removed from the buffer.intread()Read a byte from the input stream, blocking if necessary.intread(byte[] dest) Read bytes from the input stream.intread(byte[] dest, int off, int len) Read a specified number of bytes from the input stream.voidsetContentLength(int value) set the maximum number of bytes allowed to be read from this input stream.voidset the input stream to be used for subsequent readsintskip(int len) skip over (and discard) a specified number of bytes in this input streamMethods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
NonBlockingBufferedInputStream
public NonBlockingBufferedInputStream()
-
-
Method Details
-
setInputStream
set the input stream to be used for subsequent reads- Parameters:
in- the InputStream
-
setContentLength
public void setContentLength(int value) set the maximum number of bytes allowed to be read from this input stream.- Parameters:
value- the Content Length
-
read
Read a byte from the input stream, blocking if necessary. Internally the data is buffered for efficiency.- Specified by:
readin classInputStream- Returns:
- the byte read
- Throws:
IOException
-
read
Read bytes from the input stream. This is guaranteed to return at least one byte or throw an exception. When possible, it will return more bytes, up to the length of the array, as long as doing so would not require waiting on bytes from the input stream.- Overrides:
readin classInputStream- Parameters:
dest- byte array to read into- Returns:
- the number of bytes actually read
- Throws:
IOException
-
read
Read a specified number of bytes from the input stream. This is guaranteed to return at least one byte or throw an execption. When possible, it will return more bytes, up to the length specified, as long as doing so would not require waiting on bytes from the input stream.- Overrides:
readin classInputStream- Parameters:
dest- byte array to read intooff- starting offset into the byte arraylen- maximum number of bytes to read- Returns:
- the number of bytes actually read
- Throws:
IOException
-
skip
skip over (and discard) a specified number of bytes in this input stream- Parameters:
len- the number of bytes to be skipped- Returns:
- the action number of bytes skipped
- Throws:
IOException
-
available
return the number of bytes available to be read without blocking- Overrides:
availablein classInputStream- Returns:
- the number of bytes
- Throws:
IOException
-
close
disassociate from the underlying input stream- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
peek
Just like read except byte is not removed from the buffer. the data is buffered for efficiency. Was added to support multiline http headers. ;-)- Returns:
- the byte read
- Throws:
IOException
-