org.geotools.io
Class EchoWriter

Object
  extended by Writer
      extended by FilterWriter
          extended by EchoWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable

public class EchoWriter
extends FilterWriter

A writer that copy all output to an other stream. This writer can be used for perfoming an exact copy of what is sent to an other writer. For example, it may be used for echoing to the standard output the content sent to a file. This writer is usefull for debugging purpose.

Since:
2.1
Author:
Martin Desruisseaux (IRD)
Module:

Field Summary
 
Fields inherited from class FilterWriter
out
 
Fields inherited from class Writer
lock
 
Constructor Summary
EchoWriter(Writer main)
          Creates a writer that will echo to the standard output.
EchoWriter(Writer main, Writer echo)
          Creates a copy writter for the specified stream.
 
Method Summary
 void close()
          Closes the main stream and the echo stream.
 void flush()
          Flushs both streams.
 void write(char[] cbuf)
          Writes an array of characters.
 void write(char[] cbuf, int offset, int length)
          Writes a portion of an array of characters.
 void write(int c)
          Writes a single character.
 void write(String string)
          Writes a string.
 void write(String string, int offset, int length)
          Writes a portion of a string.
 
Methods inherited from class Writer
append, append, append
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EchoWriter

public EchoWriter(Writer main)
Creates a writer that will echo to the standard output. Each line to that standard output will be numbered.

Parameters:
main - The main stream.

EchoWriter

public EchoWriter(Writer main,
                  Writer echo)
Creates a copy writter for the specified stream.

Parameters:
main - The main stream.
echo - The echo stream.
Method Detail

write

public void write(int c)
           throws IOException
Writes a single character.

Overrides:
write in class FilterWriter
Parameters:
c - The character to write.
Throws:
IOException - If an I/O error occurs.

write

public void write(char[] cbuf)
           throws IOException
Writes an array of characters.

Overrides:
write in class Writer
Parameters:
cbuf - Buffer of characters to be written.
Throws:
IOException - If an I/O error occurs.

write

public void write(char[] cbuf,
                  int offset,
                  int length)
           throws IOException
Writes a portion of an array of characters.

Overrides:
write in class FilterWriter
Parameters:
cbuf - Buffer of characters to be written.
offset - Offset from which to start reading characters.
length - Number of characters to be written.
Throws:
IOException - If an I/O error occurs.

write

public void write(String string)
           throws IOException
Writes a string.

Overrides:
write in class Writer
Parameters:
string - String to be written.
Throws:
IOException - If an I/O error occurs.

write

public void write(String string,
                  int offset,
                  int length)
           throws IOException
Writes a portion of a string.

Overrides:
write in class FilterWriter
Parameters:
string - String to be written.
offset - Offset from which to start writing characters.
length - Number of characters to write.
Throws:
IOException - If an I/O error occurs.

flush

public void flush()
           throws IOException
Flushs both streams.

Specified by:
flush in interface Flushable
Overrides:
flush in class FilterWriter
Throws:
IOException - If an I/O error occurs.

close

public void close()
           throws IOException
Closes the main stream and the echo stream. In the particular case of writers created with the one argument constructor, the echo stream will not be closed since it maps to the standard output.

Specified by:
close in interface Closeable
Overrides:
close in class FilterWriter
Throws:
IOException - If an I/O error occurs.


Copyright © 1996-2009 Geotools. All Rights Reserved.