javax.servlet
Class ServletOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by javax.servlet.ServletOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable
Direct Known Subclasses:
ServletOutputStreamImpl

public abstract class ServletOutputStream
extends java.io.OutputStream

Servlets can use ServletOutputStream to write binary data to the response. ServletOutputStream provides several methods similar to the methods of PrintWriter.

Typically, servlets will use response.getOutputStream to get this object.

Note, the PrintWriter-like methods do not handle character encoding properly. If you need non-ascii character output, use getWriter().

Buffering of the output stream is controlled by the Response object.


Constructor Summary
protected ServletOutputStream()
           
 
Method Summary
 void print(boolean b)
          Prints a boolean value to output.
 void print(char c)
          Prints a character to the output.
 void print(double d)
          Prints a double to the output.
 void print(float f)
          Prints a float to the output.
 void print(int i)
          Prints an integer to the output.
 void print(long l)
          Prints a long to the output.
 void print(java.lang.String s)
          Prints a string to the stream.
 void println()
          Prints a newline to the output.
 void println(boolean b)
          Prints a boolean to the output, followed by a newline.
 void println(char c)
          Prints a character to the output, followed by a newline.
 void println(double d)
          Prints a double to the output, followed by a newline.
 void println(float f)
          Prints a float to the output, followed by a newline.
 void println(int i)
          Prints an integer to the output, followed by a newline.
 void println(long l)
          Prints a long to the output, followed by a newline.
 void println(java.lang.String s)
          Prints a string to the output, followed by a newline.
 
Methods inherited from class java.io.OutputStream
close, flush, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletOutputStream

protected ServletOutputStream()
Method Detail

print

public void print(java.lang.String s)
           throws java.io.IOException
Prints a string to the stream. Note, this method does not properly handle character encoding.

Parameters:
s - the string to write.
Throws:
java.io.IOException

print

public void print(boolean b)
           throws java.io.IOException
Prints a boolean value to output.

Parameters:
b - the boolean value
Throws:
java.io.IOException

print

public void print(char c)
           throws java.io.IOException
Prints a character to the output. Note, this doesn't handle character encoding properly.

Parameters:
c - the character value
Throws:
java.io.IOException

print

public void print(int i)
           throws java.io.IOException
Prints an integer to the output.

Parameters:
i - the integer value
Throws:
java.io.IOException

print

public void print(long l)
           throws java.io.IOException
Prints a long to the output.

Parameters:
l - the long value
Throws:
java.io.IOException

print

public void print(float f)
           throws java.io.IOException
Prints a float to the output.

Parameters:
f - the float value
Throws:
java.io.IOException

print

public void print(double d)
           throws java.io.IOException
Prints a double to the output.

Parameters:
d - the double value
Throws:
java.io.IOException

println

public void println()
             throws java.io.IOException
Prints a newline to the output.

Throws:
java.io.IOException

println

public void println(java.lang.String s)
             throws java.io.IOException
Prints a string to the output, followed by a newline. Note, character encoding is not properly handled.

Parameters:
s - the string value
Throws:
java.io.IOException

println

public void println(boolean b)
             throws java.io.IOException
Prints a boolean to the output, followed by a newline.

Parameters:
b - the boolean value
Throws:
java.io.IOException

println

public void println(char c)
             throws java.io.IOException
Prints a character to the output, followed by a newline. Note, character encoding is not properly handled.

Parameters:
c - the character value
Throws:
java.io.IOException

println

public void println(int i)
             throws java.io.IOException
Prints an integer to the output, followed by a newline.

Parameters:
i - the integer value
Throws:
java.io.IOException

println

public void println(long l)
             throws java.io.IOException
Prints a long to the output, followed by a newline.

Parameters:
l - the long value
Throws:
java.io.IOException

println

public void println(float f)
             throws java.io.IOException
Prints a float to the output, followed by a newline.

Parameters:
f - the float value
Throws:
java.io.IOException

println

public void println(double d)
             throws java.io.IOException
Prints a double to the output, followed by a newline.

Parameters:
d - the double value
Throws:
java.io.IOException