org.rhq.enterprise.agent
Class AgentPrintWriter
java.lang.Object
java.io.Writer
java.io.PrintWriter
org.rhq.enterprise.agent.AgentPrintWriter
- All Implemented Interfaces:
- Closeable, Flushable, Appendable
public class AgentPrintWriter
- extends PrintWriter
Wrapper around PrintWriter that allows you to also divert the
output to a listener.
Since all print(), println(), and some write() type methods
boil down to calls to the write() methods in PrintWriter,
this method merely overrrides the appropriate write() methods
so it can send the bytes being written to a listener,
prior to actually writing the bytes to the underlying
PrintWriter stream.
- Author:
- John Mazzitelli
| Methods inherited from class java.io.PrintWriter |
append, append, append, checkError, clearError, close, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, setError, write, write |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AgentPrintWriter
public AgentPrintWriter(PrintStream out,
boolean b)
AgentPrintWriter
public AgentPrintWriter(FileWriter fileWriter,
boolean b)
addListener
public void addListener(Writer listener)
- Adds the given writer object as a listener to this print writer.
Anything written to this print writer is also written to this
listener. You can have more than one listener. When done,
you must remove the listener via
removeListener(Writer).
- Parameters:
listener - the writer to add as a listener
removeListener
public void removeListener(Writer listener)
- Removes the given listener from the list. If the listener
was not listening to this agent print writer object, this
method does nothing and returns normally.
This method will never attempt to close the writer.
- Parameters:
listener - the listener to remove
write
public void write(char[] buf,
int off,
int len)
- Overrides:
write in class PrintWriter
write
public void write(int c)
- Overrides:
write in class PrintWriter
write
public void write(String s,
int off,
int len)
- Overrides:
write in class PrintWriter
println
public void println()
- Overrides:
println in class PrintWriter
flush
public void flush()
- Specified by:
flush in interface Flushable- Overrides:
flush in class PrintWriter
Copyright © 2008-2011 Red Hat, Inc.. All Rights Reserved.