ServletInputStream

Java Servlet Programming, 2nd Edition > A. Servlet API Quick Reference > ServletInputStream

 
< BACKCONTINUE >
ServletInputStream

Synopsis

Class Name: javax.servlet.ServletInputStream

Superclass: java.io.InputStream

Immediate Subclasses: None

Interfaces Implemented: None

Availability: Servlet API 1.0 and later

Description

Provides an input stream for reading binary data from a client request, including a readLine( ) method for reading data one line at a time. A ServletInputStream is returned by the getInputStream( ) method of ServletRequest. For HTTP servlets the ServletInputStream provides access to the submitted POST data.

Class Summary

public abstract class ServletInputStream extends java.io.InputStream {   // Constructors   protected ServletInputStream();   // Instance methods   public int readLine(byte b[], int off, int len) throws IOException; }

Constructors

ServletInputStream()

protected ServletInputStream()
Description

The default constructor does nothing. A servlet should never construct its own ServletInputStream.

Instance Methods

readLine()

public int readLine(byte b[], int off, int len) throws IOException
Description

Reads bytes from the input stream into the byte array b, starting at an offset in the array given by off. It stops reading when it encounters an \n or it has read len number of bytes. The ending \n character is read into the buffer as well. Returns the number of bytes read or -1 if the end of the stream is reached. The version of this class provided with Servlet API 2.0 had a bug where the len parameter was ignored, causing an ArrayIndexOutOfBoundsException when reading a line longer than the buffer. This was fixed in Servlet API 2.1.


Last updated on 3/20/2003
Java Servlet Programming, 2nd Edition, © 2001 O'Reilly

< BACKCONTINUE >


Java servlet programming
Java Servlet Programming (Java Series)
ISBN: 0596000405
EAN: 2147483647
Year: 2000
Pages: 223

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net