Package com.norconex.commons.lang.io
Class InputStreamLineListener
java.lang.Object
com.norconex.commons.lang.io.InputStreamLineListener
- All Implemented Interfaces:
IInputStreamListener
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.- Author:
- Pascal Essiembre
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a line listener with UTF-8 character encoding.InputStreamLineListener(String charset) Creates a line listener with supplied character encoding (defaults to UTF-8 if null).InputStreamLineListener(Charset charset) Creates a line listener with supplied character encoding (defaults to UTF-8 if null). -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidlineStreamed(String type, String line) Invoked when a line is streamed.voidInvoked when a chunk of bytes is streamed.
-
Constructor Details
-
InputStreamLineListener
public 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
-
streamed
Description copied from interface:IInputStreamListenerInvoked when a chunk of bytes is streamed.- Specified by:
streamedin interfaceIInputStreamListener- 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
-