Class FileLinesCollection

java.lang.Object
java.util.AbstractCollection<MutableString>
it.unimi.dsi.big.io.FileLinesCollection
All Implemented Interfaces:
Size64, Iterable<MutableString>, Collection<MutableString>

@Deprecated public class FileLinesCollection extends AbstractCollection<MutableString> implements Size64
Deprecated.
Please use FileLinesMutableStringIterable instead; the zipped option of this class can be simulated by passing a GZIPInputStream as decompressor.
A wrapper exhibiting the lines of a file as a Collection.

Warning: the lines returned by iterators generated by instances of this class are not cacheable. The returned value is a MutableString instance that is reused at each call, and that is modified by a call to hasNext(). Thus, for instance,

 ObjectIterators.unwrap(fileLinesColletion.iterator());
 
will not give the expected results. Use allLines() to get the big list of all lines (again, under the form of compact MutableStrings). Note also that toString() will return a single string containing all file lines separated by the string associated with the system property line.separator.

An instance of this class allows to access the lines of a file as a Collection. 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.

Since:
2.0
Author:
Sebastiano Vigna