public abstract class LineOrientedOutputStream extends OutputStream
processLine
whenever a full line has
been written to this stream.
Tries to be smart about line separators.
Constructor and Description |
---|
LineOrientedOutputStream() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Writes all remaining
|
void |
flush()
Flush this log stream
|
protected void |
processBuffer()
Converts the buffer to a byte[] and sends it to
processLine |
protected void |
processLine(byte[] line)
Processes a line.
|
protected abstract void |
processLine(String line)
Processes a line.
|
void |
write(byte[] b,
int off,
int len)
Write a block of characters to the output stream
|
void |
write(int cc)
Write the data to the buffer and flush the buffer, if a line
separator is detected.
|
write
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
- if there is an error.public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
- if there is an error.protected void processBuffer() throws IOException
processLine
IOException
- if there is an error.protected void processLine(byte[] line) throws IOException
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.
line
- the line to log.IOException
- if there is an error.protected abstract void processLine(String line) throws IOException
line
- the line to log.IOException
- if there is an error.public final void write(byte[] b, int off, int len) throws IOException
write
in class OutputStream
b
- the array containing the dataoff
- the offset into the array where data startslen
- the length of blockIOException
- if the data cannot be written into the stream.public final void write(int cc) throws IOException
write
in class OutputStream
cc
- data to log (byte).IOException
- if there is an error.