public class MultiReadable extends Object implements CharReadable
CharReadable into one. There will never be one read which reads from multiple sources.
If the end of one source is reached those (smaller amount of) characters are returned as one read and the next
read will start reading from the new source.
Newline will be injected in between two sources, even if the former doesn't end with such. This to not have the
last line in the former and first in the latter to look like one long line, if reading characters off of this
reader character by character (w/o knowing that there are multiple sources underneath).CharReadable.AdapterEMPTY| Constructor and Description |
|---|
MultiReadable(RawIterator<CharReadable,IOException> readers) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
long |
length() |
long |
position() |
int |
read(char[] into,
int offset,
int length)
Reads characters into the given array starting at
offset, reading length number of characters. |
SectionedCharBuffer |
read(SectionedCharBuffer buffer,
int from)
Reads characters into the
buffer. |
String |
sourceDescription() |
public MultiReadable(RawIterator<CharReadable,IOException> readers)
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic String sourceDescription()
sourceDescription in interface SourceTraceabilitypublic long position()
position in interface SourceTraceabilitypublic SectionedCharBuffer read(SectionedCharBuffer buffer, int from) throws IOException
CharReadablebuffer.
This method will block until data is available, an I/O error occurs, or the end of the stream is reached.
The caller is responsible for passing in from which index existing characters should be saved,
using compaction, before reading into the
front section of the buffer, using SectionedCharBuffer.readFrom(Reader).
The returned SectionedCharBuffer can be the same as got passed in, or another buffer if f.ex.
double-buffering is used. If this reader reached eof, i.e. equal state to that of Reader.read(char[])
returning -1 then SectionedCharBuffer.hasAvailable() for the returned instances will
return false.read in interface CharReadablebuffer - SectionedCharBuffer to read new data into.from - index into the buffer array where characters to save (compact) starts (inclusive).SectionedCharBuffer containing new data.IOException - if an I/O error occurs.public int read(char[] into,
int offset,
int length)
throws IOException
CharReadableoffset, reading length number of characters.
Similar to Reader.read(char[], int, int)read in interface CharReadableinto - char[] to read the data into.offset - offset to start reading into the char[].length - number of bytes to read maximum.IOException - on read error.public long length()
length in interface CharReadableCopyright © 2016–2021 MWARE SOLUTIONS. All rights reserved.