Package com.avrix.logs
Class LineReadingOutputStream
java.lang.Object
java.io.OutputStream
com.avrix.logs.LineReadingOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
An OutputStream implementation that reads byte arrays, interprets them as lines of text,
and processes each line based on specific rules for logging or consumption.
-
Constructor Summary
ConstructorsConstructorDescriptionLineReadingOutputStream(Consumer<String> consumer) Constructs a LineReadingOutputStream with the specified consumer. -
Method Summary
Methods inherited from class java.io.OutputStream
flush, nullOutputStream, write
-
Constructor Details
-
LineReadingOutputStream
Constructs a LineReadingOutputStream with the specified consumer.- Parameters:
consumer- The consumer to accept processed lines.- Throws:
NullPointerException- if the consumer is null.
-
-
Method Details
-
write
Writes a single byte to this output stream.- Specified by:
writein classOutputStream- Parameters:
b- The byte to be written.- Throws:
IOException- if an I/O error occurs.
-
write
public void write(byte[] b, int start, int len) Writes a portion of a byte array to this output stream.- Overrides:
writein classOutputStream- Parameters:
b- The data.start- The start offset in the data.len- The number of bytes to write.- Throws:
IllegalArgumentException- if the start or len is negative, or end exceeds the array length.
-
close
public void close()Closes this output stream and flushes any accumulated data if present.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream
-