Methods Summary |
---|
public final void | close()Writes all remaining
if (buffer.size() > 0) {
processBuffer();
}
super.close();
|
public final void | flush()Flush this log stream
if (buffer.size() > 0) {
processBuffer();
}
|
protected void | processBuffer()Converts the buffer to a string and sends it to
processLine
try {
processLine(buffer.toString());
} finally {
buffer.reset();
}
|
protected abstract void | processLine(java.lang.String line)Processes a line.
|
public final void | write(int cc)Write the data to the buffer and flush the buffer, if a line
separator is detected.
final byte c = (byte) cc;
if ((c == LF) || (c == CR)) {
if (!skip) {
processBuffer();
}
} else {
buffer.write(cc);
}
skip = (c == CR);
|
public final void | write(byte[] b, int off, int len)Write a block of characters to the output stream
// find the line breaks and pass other chars through in blocks
int offset = off;
int blockStartOffset = offset;
int remaining = len;
while (remaining > 0) {
while (remaining > 0 && b[offset] != LF && b[offset] != CR) {
offset++;
remaining--;
}
// either end of buffer or a line separator char
int blockLength = offset - blockStartOffset;
if (blockLength > 0) {
buffer.write(b, blockStartOffset, blockLength);
}
while (remaining > 0 && (b[offset] == LF || b[offset] == CR)) {
write(b[offset]);
offset++;
remaining--;
}
blockStartOffset = offset;
}
|