Class FileLinesByteArrayCollection
- java.lang.Object
-
- java.util.AbstractCollection<byte[]>
-
- it.unimi.dsi.big.io.FileLinesByteArrayCollection
-
- All Implemented Interfaces:
Size64,Iterable<byte[]>,Collection<byte[]>
public class FileLinesByteArrayCollection extends AbstractCollection<byte[]> implements Size64
A wrapper exhibiting the lines of a file as aCollectionof byte arrays.An instance of this class allows to access the lines of a file as a
Collectionof byte arrays. Reading is performed usingFastBufferedInputStream.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) isCloseable, and should be closed after usage.Using a suitable constructor, it is possible to specify that the file is compressed in
gzipformat (in this case, it will be opened using aGZIPInputStream).Note that the first call to
size64()will require a full file scan.- Since:
- 2.2.8
- Author:
- Sebastiano Vigna
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFileLinesByteArrayCollection.FileLinesIteratorAn iterator over the lines of aFileLinesByteArrayCollection.
-
Constructor Summary
Constructors Constructor 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 usinggzipformat, 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 usinggzipformat, using the specified line terminators.
-
Method Summary
Modifier and Type Method Description ObjectBigList<byte[]>allLines()Returns all lines of the file wrapped by this file-lines collection.FileLinesByteArrayCollection.FileLinesIteratoriterator()intsize()Deprecated.Please usesize64()instead.longsize64()Object[]toArray()Deprecated.<T> T[]toArray(T[] a)Deprecated.StringtoString()-
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
-
-
-
Constructor Detail
-
FileLinesByteArrayCollection
public FileLinesByteArrayCollection(CharSequence filename)
Creates a byte-array file-lines collection for the specified filename, using both CR and LF as line terminators.- Parameters:
filename- a filename.
-
FileLinesByteArrayCollection
public FileLinesByteArrayCollection(CharSequence filename, boolean zipped)
Creates a byte-array file-lines collection for the specified filename, optionally assuming that the file is compressed usinggzipformat, using both CR and LF as line terminators.- Parameters:
filename- a filename.zipped- whetherfilenameis zipped.
-
FileLinesByteArrayCollection
public 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 usinggzipformat, using the specified line terminators.- Parameters:
filename- a filename.zipped- whetherfilenameis zipped.terminators- line terminators for the underlyingFastBufferedInputStream.
-
-
Method Detail
-
iterator
public FileLinesByteArrayCollection.FileLinesIterator iterator()
- Specified by:
iteratorin interfaceCollection<byte[]>- Specified by:
iteratorin interfaceIterable<byte[]>- Specified by:
iteratorin classAbstractCollection<byte[]>
-
size
@Deprecated public int size()
Deprecated.Please usesize64()instead.- Specified by:
sizein interfaceCollection<byte[]>- Specified by:
sizein interfaceSize64- Specified by:
sizein classAbstractCollection<byte[]>
-
allLines
public ObjectBigList<byte[]> allLines()
Returns all lines of the file wrapped by this file-lines collection.- Returns:
- all lines of the file wrapped by this file-lines collection.
-
toArray
@Deprecated public Object[] toArray()
Deprecated.- Specified by:
toArrayin interfaceCollection<byte[]>- Overrides:
toArrayin classAbstractCollection<byte[]>
-
toArray
@Deprecated public <T> T[] toArray(T[] a)
Deprecated.- Specified by:
toArrayin interfaceCollection<byte[]>- Overrides:
toArrayin classAbstractCollection<byte[]>
-
toString
public String toString()
- Overrides:
toStringin classAbstractCollection<byte[]>
-
-