Package com.norconex.commons.lang.io
Class InputStreamLineListener
- java.lang.Object
-
- com.norconex.commons.lang.io.InputStreamLineListener
-
- All Implemented Interfaces:
IInputStreamListener
public abstract class InputStreamLineListener extends Object implements 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 eachInputStreamConsumerto prevent lines content being mixed up.- Author:
- Pascal Essiembre
- See Also:
InputStreamConsumer
-
-
Constructor Summary
Constructors Constructor Description InputStreamLineListener()Creates 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
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidlineStreamed(String type, String line)Invoked when a line is streamed.voidstreamed(String type, byte[] bytes, int length)Invoked when a chunk of bytes is streamed.
-
-
-
Constructor Detail
-
InputStreamLineListener
public InputStreamLineListener()
Creates a line listener with UTF-8 character encoding.
-
InputStreamLineListener
public InputStreamLineListener(Charset charset)
Creates a line listener with supplied character encoding (defaults to UTF-8 if null).- Parameters:
charset- character encoding
-
InputStreamLineListener
public InputStreamLineListener(String charset)
Creates a line listener with supplied character encoding (defaults to UTF-8 if null).- Parameters:
charset- character encoding
-
-
Method Detail
-
streamed
public void streamed(String type, byte[] bytes, int length)
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
-
-