Home » openjdk-7 » java » io » [javadoc | source]

    1   /*
    2    * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved.
    3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    4    *
    5    * This code is free software; you can redistribute it and/or modify it
    6    * under the terms of the GNU General Public License version 2 only, as
    7    * published by the Free Software Foundation.  Oracle designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Oracle in the LICENSE file that accompanied this code.
   10    *
   11    * This code is distributed in the hope that it will be useful, but WITHOUT
   12    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13    * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14    * version 2 for more details (a copy is included in the LICENSE file that
   15    * accompanied this code).
   16    *
   17    * You should have received a copy of the GNU General Public License version
   18    * 2 along with this work; if not, write to the Free Software Foundation,
   19    * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20    *
   21    * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   22    * or visit www.oracle.com if you need additional information or have any
   23    * questions.
   24    */
   25   
   26   package java.io;
   27   
   28   
   29   /**
   30    * Abstract class for writing filtered character streams.
   31    * The abstract class <code>FilterWriter</code> itself
   32    * provides default methods that pass all requests to the
   33    * contained stream. Subclasses of <code>FilterWriter</code>
   34    * should override some of these methods and may also
   35    * provide additional methods and fields.
   36    *
   37    * @author      Mark Reinhold
   38    * @since       JDK1.1
   39    */
   40   
   41   public abstract class FilterWriter extends Writer {
   42   
   43       /**
   44        * The underlying character-output stream.
   45        */
   46       protected Writer out;
   47   
   48       /**
   49        * Create a new filtered writer.
   50        *
   51        * @param out  a Writer object to provide the underlying stream.
   52        * @throws NullPointerException if <code>out</code> is <code>null</code>
   53        */
   54       protected FilterWriter(Writer out) {
   55           super(out);
   56           this.out = out;
   57       }
   58   
   59       /**
   60        * Writes a single character.
   61        *
   62        * @exception  IOException  If an I/O error occurs
   63        */
   64       public void write(int c) throws IOException {
   65           out.write(c);
   66       }
   67   
   68       /**
   69        * Writes a portion of an array of characters.
   70        *
   71        * @param  cbuf  Buffer of characters to be written
   72        * @param  off   Offset from which to start reading characters
   73        * @param  len   Number of characters to be written
   74        *
   75        * @exception  IOException  If an I/O error occurs
   76        */
   77       public void write(char cbuf[], int off, int len) throws IOException {
   78           out.write(cbuf, off, len);
   79       }
   80   
   81       /**
   82        * Writes a portion of a string.
   83        *
   84        * @param  str  String to be written
   85        * @param  off  Offset from which to start reading characters
   86        * @param  len  Number of characters to be written
   87        *
   88        * @exception  IOException  If an I/O error occurs
   89        */
   90       public void write(String str, int off, int len) throws IOException {
   91           out.write(str, off, len);
   92       }
   93   
   94       /**
   95        * Flushes the stream.
   96        *
   97        * @exception  IOException  If an I/O error occurs
   98        */
   99       public void flush() throws IOException {
  100           out.flush();
  101       }
  102   
  103       public void close() throws IOException {
  104           out.close();
  105       }
  106   
  107   }

Home » openjdk-7 » java » io » [javadoc | source]