public abstract class ServletInputStream extends InputStream
readLine
method
for reading data one line at a time. With some protocols, such
as HTTP POST and PUT, a ServletInputStream
object can be used to read data sent from the client.
A ServletInputStream
object is normally retrieved via
the ServletRequest.getInputStream()
method.
This is an abstract class that a servlet container implements.
Subclasses of this class
must implement the java.io.InputStream.read()
method.
ServletRequest
Modifier | Constructor and Description |
---|---|
protected |
ServletInputStream()
Does nothing, because this is an abstract class.
|
Modifier and Type | Method and Description |
---|---|
abstract boolean |
isFinished()
Returns true when all the data from the stream has been read else
it returns false.
|
abstract boolean |
isReady()
Returns true if data can be read without blocking else returns
false.
|
int |
readLine(byte[] b,
int off,
int len)
Reads the input stream, one line at a time.
|
abstract void |
setReadListener(ReadListener readListener)
Instructs the
ServletInputStream to invoke the provided
ReadListener when it is possible to read |
available, close, mark, markSupported, read, read, read, reset, skip
protected ServletInputStream()
public int readLine(byte[] b, int off, int len) throws IOException
This method returns -1 if it reaches the end of the input stream before reading the maximum number of bytes.
b
- an array of bytes into which data is readoff
- an integer specifying the character at which
this method begins readinglen
- an integer specifying the maximum number of
bytes to readIOException
- if an input or output exception has occurredpublic abstract boolean isFinished()
true
when all data for this particular request
has been read, otherwise returns false
.public abstract boolean isReady()
true
if data can be obtained without blocking,
otherwise returns false
.public abstract void setReadListener(ReadListener readListener)
ServletInputStream
to invoke the provided
ReadListener
when it is possible to readreadListener
- the ReadListener
that should be notified
when it's possible to read.IllegalStateException
- if one of the following conditions is true
NullPointerException
- if readListener is nullCopyright © 2016 JBoss by Red Hat. All rights reserved.