FileDocCategorySizeDatePackage
FilterWriter.javaAPI DocAndroid 1.5 API4716Wed May 06 22:41:04 BST 2009java.io

FilterWriter

public abstract class FilterWriter extends Writer
Wraps an existing {@link Writer} and performs some transformation on the output data while it is being written. Transformations can be anything from a simple byte-wise filtering output data to an on-the-fly compression or decompression of the underlying writer. Writers that wrap another writer and provide some additional functionality on top of it usually inherit from this class.
see
FilterReader
since
Android 1.0

Fields Summary
protected Writer
out
The Writer being filtered.
Constructors Summary
protected FilterWriter(Writer out)
Constructs a new FilterWriter on the Writer {@code out}. All writes are now filtered through this writer.

param
out the target Writer to filter writes on.
since
Android 1.0

        super(out);
        this.out = out;
    
Methods Summary
public voidclose()
Closes this writer. This implementation closes the target writer.

throws
IOException if an error occurs attempting to close this writer.
since
Android 1.0

        synchronized (lock) {
            out.close();
        }
    
public voidflush()
Flushes this writer to ensure all pending data is sent out to the target writer. This implementation flushes the target writer.

throws
IOException if an error occurs attempting to flush this writer.
since
Android 1.0

        synchronized (lock) {
            out.flush();
        }
    
public voidwrite(char[] buffer, int offset, int count)
Writes {@code count} characters from the char array {@code buffer} starting at position {@code offset} to the target writer.

param
buffer the buffer to write.
param
offset the index of the first character in {@code buffer} to write.
param
count the number of characters in {@code buffer} to write.
throws
IOException if an error occurs while writing to this writer.
since
Android 1.0

        // BEGIN android-note
        // changed array notation to be consistent with the rest of harmony
        // END android-note
        synchronized (lock) {
            out.write(buffer, offset, count);
        }
    
public voidwrite(int oneChar)
Writes the specified character {@code oneChar} to the target writer. Only the two least significant bytes of the integer {@code oneChar} are written.

param
oneChar the char to write to the target writer.
throws
IOException if an error occurs while writing to this writer.
since
Android 1.0

        synchronized (lock) {
            out.write(oneChar);
        }
    
public voidwrite(java.lang.String str, int offset, int count)
Writes {@code count} characters from the string {@code str} starting at position {@code index} to this writer. This implementation writes {@code str} to the target writer.

param
str the string to be written.
param
offset the index of the first character in {@code str} to write.
param
count the number of chars in {@code str} to write.
throws
IOException if an error occurs while writing to this writer.
since
Android 1.0

        synchronized (lock) {
            out.write(str, offset, count);
        }