public class FileLinesByteArrayCollection extends AbstractCollection<byte[]> implements Size64
Collection of byte arrays.
An instance of this class allows to access the lines of a file as a
Collection of byte arrays. Reading is performed using
FastBufferedInputStream.readLine(byte[], EnumSet), and follows the rules defined therein.
No decoding is performed.
Using direct access is strongly discouraged (it will require a full scan of the file), but
the iterator() can be fruitfully used to scan the file, and can be called any
number of times, as it opens an independent input stream at each call. For the
same reason, the returned iterator type (FileLinesCollection.FileLinesIterator)
is Closeable, and should be closed after usage.
Using a suitable constructor, it is possible
to specify that the file is compressed in gzip format (in this case, it will be opened using a GZIPInputStream).
Note that the first call to size64() will require a full file scan.
| Modifier and Type | Class and Description |
|---|---|
static class |
FileLinesByteArrayCollection.FileLinesIterator
An iterator over the lines of a
FileLinesByteArrayCollection. |
| Constructor and Description |
|---|
FileLinesByteArrayCollection(CharSequence filename)
Creates a byte-array file-lines collection for the specified filename, using both CR and LF as line terminators.
|
FileLinesByteArrayCollection(CharSequence filename,
boolean zipped)
Creates a byte-array file-lines collection for the specified filename, optionally assuming
that the file is compressed using
gzip format, using both CR and LF as line terminators. |
FileLinesByteArrayCollection(CharSequence filename,
boolean zipped,
EnumSet<FastBufferedInputStream.LineTerminator> terminators)
Creates a byte-array file-lines collection for the specified filename, optionally assuming
that the file is compressed using
gzip format, using the specified line terminators. |
| Modifier and Type | Method and Description |
|---|---|
ObjectBigList<byte[]> |
allLines()
Returns all lines of the file wrapped by this file-lines collection.
|
FileLinesByteArrayCollection.FileLinesIterator |
iterator() |
int |
size() |
long |
size64() |
Object[] |
toArray()
Deprecated.
|
<T> T[] |
toArray(T[] a)
Deprecated.
|
String |
toString() |
add, addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAllclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitequals, hashCode, parallelStream, removeIf, spliterator, streampublic FileLinesByteArrayCollection(CharSequence filename)
filename - a filename.public FileLinesByteArrayCollection(CharSequence filename, boolean zipped)
gzip format, using both CR and LF as line terminators.filename - a filename.zipped - whether filename is zipped.public FileLinesByteArrayCollection(CharSequence filename, boolean zipped, EnumSet<FastBufferedInputStream.LineTerminator> terminators)
gzip format, using the specified line terminators.filename - a filename.zipped - whether filename is zipped.terminators - line terminators for the underlying FastBufferedInputStream.public FileLinesByteArrayCollection.FileLinesIterator iterator()
iterator in interface Iterable<byte[]>iterator in interface Collection<byte[]>iterator in class AbstractCollection<byte[]>public int size()
size in interface Size64size in interface Collection<byte[]>size in class AbstractCollection<byte[]>public ObjectBigList<byte[]> allLines()
@Deprecated public Object[] toArray()
toArray in interface Collection<byte[]>toArray in class AbstractCollection<byte[]>@Deprecated public <T> T[] toArray(T[] a)
toArray in interface Collection<byte[]>toArray in class AbstractCollection<byte[]>public String toString()
toString in class AbstractCollection<byte[]>