home *** CD-ROM | disk | FTP | other *** search
/ Java Developer's Companion / Java Developer's Companion.iso / binaries / Windows / jsdk / src / javax / servlet / ServletOutputStream.java < prev    next >
Encoding:
Java Source  |  1997-07-18  |  4.6 KB  |  181 lines

  1. /*
  2.  * @(#)ServletOutputStream.java    1.9 97/05/22
  3.  * 
  4.  * Copyright (c) 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.0
  20.  */
  21.  
  22. package javax.servlet;
  23.  
  24. import java.io.OutputStream;
  25. import java.io.IOException;
  26.  
  27. /**
  28.  *
  29.  * An output stream for writing servlet responses.  This is an
  30.  * abstract class, to be implemented by a network services
  31.  * implementor.  Servlet writers use the output stream to return data
  32.  * to clients.  They access it via the ServletResponse's
  33.  * getOutputStream method, available from within the servlet's service
  34.  * method.  Subclasses of ServletOutputStream must provide an
  35.  * implementation of the write(int) method.
  36.  * 
  37.  * @see java.io.OutputStream#write(int)
  38.  *
  39.  * @version    1.9, 05/22/97
  40.  * @author David Connelly */
  41.  
  42. public abstract
  43. class ServletOutputStream extends OutputStream {
  44.  
  45.     /**
  46.      * The default constructor does no work.
  47.      */
  48.     protected ServletOutputStream () { }
  49.  
  50.  
  51.     /**
  52.      * Prints the string provided.
  53.      * @exception IOException if an I/O error has occurred
  54.      */
  55.     public void print(String s) throws IOException {
  56.     int len = s.length();
  57.     for (int i = 0; i < len; i++) {
  58.         write(s.charAt(i));
  59.     }
  60.     }
  61.  
  62.     /**
  63.      * Prints the boolean provided.
  64.      * @exception IOException if an I/O error has occurred.
  65.      */
  66.     public void print(boolean b) throws IOException {
  67.     print(b ? "true" : "false");
  68.     }
  69.  
  70.     /*
  71.      * Prints the character provided.
  72.      * @exception IOException if an I/O error has occurred
  73.      */
  74.     public void print(char c) throws IOException {
  75.     print(String.valueOf(c));
  76.     }
  77.  
  78.     /**
  79.      * Prints the integer provided.
  80.      * @exception IOException if an I/O error has occurred
  81.      */  
  82.     public void print(int i) throws IOException {
  83.     print(String.valueOf(i));
  84.     }
  85.  
  86.     /**
  87.      * Prints the long provided.
  88.      * @exception IOException if an I/O error has occurred
  89.      */
  90.     public void print(long l) throws IOException {
  91.     print(String.valueOf(l));
  92.     }
  93.  
  94.     /**
  95.      * Prints the float provided.
  96.      * @exception IOException if an I/O error has occurred
  97.      */
  98.     public void print(float f) throws IOException {
  99.     print(String.valueOf(f));
  100.     }
  101.  
  102.     /**
  103.      * Prints the double provided.
  104.      * @exception IOException if an I/O error has occurred
  105.      */
  106.     public void print(double d) throws IOException {
  107.     print(String.valueOf(d));
  108.     }
  109.  
  110.     /**
  111.      * Prints a CRLF.
  112.      * @exception IOException if an I/O error has occurred
  113.      */
  114.     public void println() throws IOException {
  115.     print("\r\n");
  116.     }
  117.  
  118.     /**
  119.      * Prints the string provided, followed by a CRLF.
  120.      * @exception IOException if an I/O error has occurred
  121.      */
  122.     public void println(String s) throws IOException {
  123.     print(s);
  124.     println();
  125.     }
  126.  
  127.     /**
  128.      * Prints the boolean provided, followed by a CRLF.
  129.      * @exception IOException if an I/O error has occurred.
  130.      */
  131.     public void println(boolean b) throws IOException {
  132.     print(b);
  133.     println();
  134.     }
  135.  
  136.     /*
  137.      * Prints the character provided, followed by a CRLF.
  138.      * @exception IOException if an I/O error has occurred
  139.      */
  140.     public void println(char c) throws IOException {
  141.     print(c);
  142.     println();
  143.     }
  144.  
  145.     /**
  146.      * Prints the integer provided, followed by a CRLF.
  147.      * @exception IOException if an I/O error has occurred
  148.      */
  149.     public void println(int i) throws IOException {
  150.     print(i);
  151.     println();
  152.     }
  153.  
  154.     /**  
  155.      * Prints the long provided, followed by a CRLF.
  156.      * @exception IOException if an I/O error has occurred
  157.      */  
  158.     public void println(long l) throws IOException {
  159.     print(l);
  160.     println();
  161.     }
  162.  
  163.     /**
  164.      * Prints the float provided, followed by a CRLF.
  165.      * @exception IOException if an I/O error has occurred
  166.      */
  167.     public void println(float f) throws IOException {
  168.     print(f);
  169.     println();
  170.     }
  171.  
  172.     /**
  173.      * Prints the double provided, followed by a CRLF.
  174.      * @exception IOException if an I/O error has occurred
  175.      */
  176.     public void println(double d) throws IOException {
  177.     print(d);
  178.     println();
  179.     }
  180. }
  181.