public class LineOrientedOutputStreamRedirector extends LineOrientedOutputStream
If the source stream doesn't end with a end of line, one will be added. This is particularly useful in combination with the OutputStreamFunneler so each funneled stream get its line.
Constructor and Description |
---|
LineOrientedOutputStreamRedirector(java.io.OutputStream stream) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Writes all remaining
|
void |
flush()
Flush this log stream
|
protected void |
processLine(byte[] b)
Processes a line.
|
protected void |
processLine(java.lang.String line)
Processes a line.
|
processBuffer, write, write
public LineOrientedOutputStreamRedirector(java.io.OutputStream stream)
protected void processLine(byte[] b) throws java.io.IOException
LineOrientedOutputStream
This implementations invokes the string-arg version converting the byte array using the default encoding. Subclasses are encouraged to override this method (and provide a dummy implementation of the String-arg version) so they don't interfere with the encoding of the underlying stream.
processLine
in class LineOrientedOutputStream
b
- the line to log.java.io.IOException
- if there is an error.protected void processLine(java.lang.String line) throws java.io.IOException
LineOrientedOutputStream
processLine
in class LineOrientedOutputStream
line
- the line to log.java.io.IOException
- if there is an error.public void close() throws java.io.IOException
LineOrientedOutputStream
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class LineOrientedOutputStream
java.io.IOException
- if there is an error.public void flush() throws java.io.IOException
LineOrientedOutputStream
flush
in interface java.io.Flushable
flush
in class LineOrientedOutputStream
java.io.IOException
- if there is an error.