Class Reader
java.lang.Object
io.github.kelsoncm.fwf.readers.Reader
-
Constructor Summary
ConstructorsConstructorDescriptionReader(Object iterable, FileDescriptor fileDescriptor) Constructs a newReaderdefaulting to newline delimiter"\n\r".Reader(Object iterable, FileDescriptor fileDescriptor, String newline) Constructs a newReaderwith a content source, file descriptor, and newline delimiter. -
Method Summary
Modifier and TypeMethodDescriptionintGets the 1-based index of the line currently being processed.intGets the total number of lines in the file.booleanhasNext()Checks if more lines remain to be read.iterator()Returns an iterator over the parsed row maps.next()Reads and parses the next line into a map of column names to parsed values.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface Iterator
forEachRemaining, remove
-
Constructor Details
-
Reader
Constructs a newReaderwith a content source, file descriptor, and newline delimiter.- Parameters:
iterable- source object (String, List of Strings, InputStream, or java.io.Reader)fileDescriptor- non-nullFileDescriptornewline- newline delimiter string ("\n","\r", or"\n\r")- Throws:
IllegalArgumentException- if any argument is invalid or line sizes do not match
-
Reader
Constructs a newReaderdefaulting to newline delimiter"\n\r".- Parameters:
iterable- source objectfileDescriptor- non-nullFileDescriptor
-
-
Method Details
-
getLinesCount
public int getLinesCount()Gets the total number of lines in the file.- Returns:
- line count
-
getLineNum
public int getLineNum()Gets the 1-based index of the line currently being processed.- Returns:
- current 1-based line number
-
iterator
-
hasNext
-
next
-