All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sun.servlet.http.HttpOutputStream

java.lang.Object
   |
   +----java.io.OutputStream
           |
           +----java.servlet.ServletOutputStream
                   |
                   +----sun.servlet.http.HttpOutputStream

public class HttpOutputStream
extends ServletOutputStream
This class implements a buffered output stream for writing servlet response data. It also keeps track of the number of bytes that have been written, and allows the specification of an optional byte limit to ensure that the content length has not been exceeded. Additionally, an observer list is maintained which can be used to notify observers the first time the stream is written to.


Variable Index

 o buf
The output buffer.
 o count
The current number of bytes in the buffer.
 o except
If set then an I/O exception is pending.
 o length
The content length for this stream.
 o limit
The maximum number of bytes that can be written.
 o obs
The observer that will be notified when the stream is first written.
 o out
The actual output stream.
 o total
The total number of bytes written so far.

Constructor Index

 o HttpOutputStream()
Creates a new, uninitialized servlet output stream with a default buffer size.
 o HttpOutputStream(int)
Creates a new servlet output stream using the specified buffer size.

Method Index

 o check(int)
Checks the output stream for a pending IOException that needs to be thrown, a content length that has been exceeded, or observers that need to be notified.
 o close()
Closes the servlet output stream.
 o finish()
Finishes the current response.
 o flush()
Flushes the output stream.
 o flushBytes()
Flushes the output stream bytes.
 o getContentLength()
Returns the content length for this output stream, or -1 if not set.
 o getTotal()
Returns the total number of bytes written so far.
 o init(OutputStream)
Initializes the output stream with the specified raw output stream.
 o next()
Begins the next response.
 o print(HttpDate)
Prints an HttpDate object.
 o print(String)
Prints a string.
 o resets()
Resets the output stream for a new connection.
 o setContentLength(int)
Sets the content length for this output stream.
 o setIOException(IOException)
Sets the pending IOException for this output stream.
 o setObserver(Observer)
Sets an observer for this output stream.
 o write(byte[], int, int)
Writes an array of bytes.
 o write(int)
Writes a byte.

Variables

 o out
  protected OutputStream out
The actual output stream.

 o buf
  protected byte buf[]
The output buffer.

 o count
  protected int count
The current number of bytes in the buffer.

 o total
  protected int total
The total number of bytes written so far.

 o limit
  protected int limit
The maximum number of bytes that can be written. This is initially set to -1 in order to indicate that observers must be notified.

 o length
  protected int length
The content length for this stream.

 o obs
  protected Observer obs
The observer that will be notified when the stream is first written.

 o except
  protected IOException except
If set then an I/O exception is pending.

Constructors

 o HttpOutputStream
  public HttpOutputStream(int size)
Creates a new servlet output stream using the specified buffer size.

Parameters:
size - the output buffer size
 o HttpOutputStream
  public HttpOutputStream()
Creates a new, uninitialized servlet output stream with a default buffer size.

Methods

 o init
  public void init(OutputStream out) throws IOException
Initializes the output stream with the specified raw output stream.

Parameters:
out - the raw output stream
 o next
  public void next()
Begins the next response.

 o finish
  public void finish() throws IOException
Finishes the current response.

 o resets
  public void resets()
Resets the output stream for a new connection.

 o getTotal
  public int getTotal()
Returns the total number of bytes written so far.

 o setContentLength
  public void setContentLength(int len)
Sets the content length for this output stream.

Parameters:
len - the content length
 o getContentLength
  public int getContentLength()
Returns the content length for this output stream, or -1 if not set.

 o setObserver
  public void setObserver(Observer obs)
Sets an observer for this output stream. The observer will be notified when the stream is first written to.

 o setIOException
  public void setIOException(IOException e)
Sets the pending IOException for this output stream.

Parameters:
e - the IOException
 o check
  protected void check(int len) throws IOException
Checks the output stream for a pending IOException that needs to be thrown, a content length that has been exceeded, or observers that need to be notified.

Parameters:
len - the number of bytes about to be written
 o write
  public void write(int b) throws IOException
Writes a byte. This method will block until the byte is actually written.

Parameters:
b - the byte
Throws: IOException
if an I/O error has occurred
Overrides:
write in class OutputStream
 o write
  public void write(byte b[],
                    int off,
                    int len) throws IOException
Writes an array of bytes. This method will block until all the bytes are actually written.

Parameters:
b - the data to be written
off - the start offset of the data
len - the number of bytes to write
Throws: IOException
if an I/O error has occurred
Overrides:
write in class OutputStream
 o flush
  public void flush() throws IOException
Flushes the output stream.

Overrides:
flush in class OutputStream
 o flushBytes
  protected void flushBytes() throws IOException
Flushes the output stream bytes.

 o print
  public void print(String s) throws IOException
Prints a string.

Throws: IOException
if an I/O error has occurred
Overrides:
print in class ServletOutputStream
 o print
  public void print(HttpDate d) throws IOException
Prints an HttpDate object.

 o close
  public void close() throws IOException
Closes the servlet output stream.

Overrides:
close in class OutputStream

All Packages  Class Hierarchy  This Package  Previous  Next  Index