Class ServletInputStream


public abstract class ServletInputStream

This class serves as a stream where servlets can read data supplied by the client from.

Servlet API 1.0
Servlet API 2.1

Constructor Summary
protected ServletInputStream()
          Does nothing.
Method Summary
 int readLine(byte[] buffer, int offset, int length)
          This method read bytes from a stream and stores them into a caller supplied buffer.
Methods inherited from class
available, close, mark, markSupported, read, read, read, reset, skip
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


protected ServletInputStream()
Does nothing.
Servlet API 1.0
Method Detail


public int readLine(byte[] buffer,
                    int offset,
                    int length)
This method read bytes from a stream and stores them into a caller supplied buffer. It starts storing the data at index offset into the buffer and attempts to read until a end of line ('\n') is encountered or length bytes are read. This method can return before reading the number of bytes requested. The actual number of bytes read is returned as an int. A -1 is returned to indicate the end of the stream. This method will block until some data can be read. This method operates by calling the single byte read() method in a loop until the desired number of bytes are read. The read loop stops short if the end of the stream is encountered or if an IOException is encountered on any read operation except the first. If the first attempt to read a bytes fails, the IOException is allowed to propagate upward. And subsequent IOException is caught and treated identically to an end of stream condition. Subclasses can (and should if possible) override this method to provide a more efficient implementation.
buffer - The array into which the bytes read should be stored
offset - The offset into the array to start storing bytes
length - The maximum number of bytes to read
The actual number of bytes read, or -1 if end of stream.
Throws: - If an error occurs.
Servlet API 1.0