Class FileLinesCollection
- java.lang.Object
-
- java.util.AbstractCollection<MutableString>
-
- it.unimi.dsi.io.FileLinesCollection
-
- All Implemented Interfaces:
java.lang.Iterable<MutableString>
,java.util.Collection<MutableString>
@Deprecated public class FileLinesCollection extends java.util.AbstractCollection<MutableString>
Deprecated.Please useFileLinesMutableStringIterable
instead; thezipped
option of this class can be simulated by passing aGZIPInputStream
as decompressor.A wrapper exhibiting the lines of a file as aCollection
.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 tohasNext()
. Thus, for instance,ObjectIterators.unwrap(fileLinesColletion.iterator());
will not give the expected results. UseallLines()
to get the list of all lines (again, under the form of compactMutableString
s). Note also thattoString()
will return a single string containing all file lines separated by the string associated with the system propertyline.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 theiterator()
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
gzip
format (in this case, it will be opened using aGZIPInputStream
).Note that the first call to
size()
will require a full file scan.- Since:
- 0.9.2
- Author:
- Sebastiano Vigna
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FileLinesCollection.FileLinesIterator
Deprecated.Please useFileLinesMutableStringIterable.iterator(java.io.InputStream, java.nio.charset.Charset, Class)
; thezipped
option of this class can be simulated by passing aGZIPInputStream
as decompressor.
-
Constructor Summary
Constructors Constructor Description FileLinesCollection(java.lang.CharSequence filename, java.lang.String encoding)
Deprecated.Creates a file-lines collection for the specified filename with the specified encoding.FileLinesCollection(java.lang.CharSequence filename, java.lang.String encoding, boolean zipped)
Deprecated.Creates a file-lines collection for the specified filename with the specified encoding, optionally assuming that the file is compressed usinggzip
format.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description it.unimi.dsi.fastutil.objects.ObjectList<MutableString>
allLines()
Deprecated.Returns all lines of the file wrapped by this file-lines collection.FileLinesCollection.FileLinesIterator
iterator()
Deprecated.int
size()
Deprecated.java.lang.Object[]
toArray()
Deprecated.<T> T[]
toArray(T[] a)
Deprecated.java.lang.String
toString()
Deprecated.-
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
-
-
-
-
Constructor Detail
-
FileLinesCollection
public FileLinesCollection(java.lang.CharSequence filename, java.lang.String encoding)
Deprecated.Creates a file-lines collection for the specified filename with the specified encoding.- Parameters:
filename
- a filename.encoding
- an encoding.
-
FileLinesCollection
public FileLinesCollection(java.lang.CharSequence filename, java.lang.String encoding, boolean zipped)
Deprecated.Creates a file-lines collection for the specified filename with the specified encoding, optionally assuming that the file is compressed usinggzip
format.- Parameters:
filename
- a filename.encoding
- an encoding.zipped
- whetherfilename
is zipped.
-
-
Method Detail
-
iterator
public FileLinesCollection.FileLinesIterator iterator()
Deprecated.- Specified by:
iterator
in interfacejava.util.Collection<MutableString>
- Specified by:
iterator
in interfacejava.lang.Iterable<MutableString>
- Specified by:
iterator
in classjava.util.AbstractCollection<MutableString>
-
size
public int size()
Deprecated.- Specified by:
size
in interfacejava.util.Collection<MutableString>
- Specified by:
size
in classjava.util.AbstractCollection<MutableString>
-
allLines
public it.unimi.dsi.fastutil.objects.ObjectList<MutableString> allLines()
Deprecated.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
public java.lang.Object[] toArray()
Deprecated.- Specified by:
toArray
in interfacejava.util.Collection<MutableString>
- Overrides:
toArray
in classjava.util.AbstractCollection<MutableString>
-
toArray
public <T> T[] toArray(T[] a)
Deprecated.- Specified by:
toArray
in interfacejava.util.Collection<MutableString>
- Overrides:
toArray
in classjava.util.AbstractCollection<MutableString>
-
toString
public java.lang.String toString()
Deprecated.- Overrides:
toString
in classjava.util.AbstractCollection<MutableString>
-
-