Package com.norconex.commons.lang.io
Class InputStreamLineListener
java.lang.Object
com.norconex.commons.lang.io.InputStreamLineListener
- All Implemented Interfaces:
InputStreamListener
Listener that is being notified every time a line is processed from a
given stream. Not thread-safe. Use a new instance for each thread or at
a minimum, make sure to give a unique type argument to
each
InputStreamConsumer to prevent lines content being mixed up.- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a line listener with UTF-8 character encoding.protectedInputStreamLineListener(String charset) Creates a line listener with supplied character encoding (defaults to UTF-8 if null).protectedInputStreamLineListener(Charset charset) Creates a line listener with supplied character encoding (defaults to UTF-8 if null). -
Method Summary
Modifier and TypeMethodDescriptionprotected CharsetGets the character encoding this listener is expected to receive.protected abstract voidlineStreamed(String type, String line) Invoked when a line is streamed.voidInvoked when a chunk of bytes is streamed.
-
Constructor Details
-
InputStreamLineListener
protected InputStreamLineListener()Creates a line listener with UTF-8 character encoding. -
InputStreamLineListener
Creates a line listener with supplied character encoding (defaults to UTF-8 if null).- Parameters:
charset- character encoding
-
InputStreamLineListener
Creates a line listener with supplied character encoding (defaults to UTF-8 if null).- Parameters:
charset- character encoding
-
-
Method Details
-
getCharset
Gets the character encoding this listener is expected to receive.- Returns:
- character encoding
- Since:
- 3.0.0
-
streamed
Description copied from interface:InputStreamListenerInvoked when a chunk of bytes is streamed.- Specified by:
streamedin interfaceInputStreamListener- Parameters:
type- type of what is being streamed, as defined by the class using this listenerbytes- chunk of bytes streamedlength- length of valid bytes to read or -1 if no more bytes to read
-
lineStreamed
Invoked when a line is streamed.- Parameters:
type- type of line, as defined by the class using the listenerline- line processed
-