public final class InputReaders extends Object
InputReader
classes.Modifier and Type | Class and Description |
---|---|
static class |
InputReaders.FileInput
Represents the file with associated charset for reading from it.
|
Modifier and Type | Method and Description |
---|---|
static InputReader |
forFile(File file,
Charset charset)
Returns the input reader for the given file.
|
static InputReader |
forFileInputProvider(InputReaders.FileInput.Provider fileProvider)
Returns the input reader reading data from the given provider.
|
static InputReader |
forReader(Reader reader)
Returns the input reader backed by the given reader.
|
static InputReader |
forStream(InputStream stream,
Charset charset)
Returns the input reader backed by the given stream.
|
@NonNull public static InputReader forReader(@NonNull Reader reader)
The client should not use the reader passed as argument anymore. When the returned input reader is closed reader passed as argument is closed respectively.
Returned reader will never call reset on InputProcessor
while
reading.
Returned reader is not thread safe so it can't be used in
multiple instances of InputReaderTask
.
reader
- real source of the data@NonNull public static InputReader forStream(@NonNull InputStream stream, @NonNull Charset charset)
The client should not use the stream passed as argument anymore. When the returned input reader is closed stream is closed respectively.
Returned reader will never call reset on InputProcessor
while
reading.
Returned reader is not thread safe so it can't be used in
multiple instances of InputReaderTask
.
stream
- real source of the datacharset
- bytes to characters conversion charset@NonNull public static InputReader forFile(@NonNull File file, @NonNull Charset charset)
Returned reader will never call reset on InputProcessor
while
reading.
Returned reader is not thread safe so it can't be used in
multiple instances of InputReaderTask
.
file
- file to read fromcharset
- bytes to characters conversion charset@NonNull public static InputReader forFileInputProvider(@NonNull InputReaders.FileInput.Provider fileProvider)
This means that the actual file (and the corresponding charset) used can change during the processing. This is specifically useful for rotating log files.
Before each read cycle reader invokes InputReaders.FileInput.Provider.getFileInput()
to determine the actual file to read.
When processing the input InputProcessor.reset()
is called on
each file change (when provided file input differs from the previous one).
Returned reader is not thread safe so it can't be used in
multiple instances of InputReaderTask
.
fileProvider
- provider used to get the file to process