Skip to Main Content
Java Servlet Programming
book

Java Servlet Programming

by Jason Hunter
November 1998
Intermediate to advanced content levelIntermediate to advanced
526 pages
14h 38m
English
O'Reilly Media, Inc.
Content preview from Java Servlet Programming

Name

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 an efficient readLine() method for reading data one line at a time. A ServletInputStream is returned by the getInputStream() method of ServletRequest. A servlet that filters binary output from other sources generally gets its input via this stream.

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. Because servlets rarely, if ever, create their own input streams, it can be safely ignored.

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.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Servlet Programming, 2nd Edition

Java Servlet Programming, 2nd Edition

Jason Hunter, William Crawford

Publisher Resources

ISBN: 156592391XSupplemental ContentCatalog PageErrata