Class FileIterator<T>

    • Constructor Summary

      Constructors 
      Constructor Description
      FileIterator​(java.io.BufferedReader reader)  
      FileIterator​(java.lang.String fileName)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Close file
      protected int countNewLineChars()
      Guess number of newline characters used (e.g.
      long getFilePointer()
      Get position within file
      java.lang.String getLine()  
      int getLineNum()  
      protected void guessNewLineChars()
      Guess number of newline characters used (e.g.
      boolean hasNext()  
      boolean hasSeek()
      Is 'seek' operation supported?
      protected void init​(java.lang.String fileName, int inOffset)
      Initialize
      boolean isDebug()  
      java.util.Iterator<T> iterator()  
      java.util.List<T> load()
      Load all elements from a file into a list
      T next()  
      protected java.lang.String readLine()
      Read a line from reader
      protected abstract T readNext()
      Read next element
      protected boolean ready()
      Is reader ready? I.e.
      void remove()  
      void seek​(long pos)
      Seek to 'pos' (jump to byte number 'pos' in the file
      void setAutoClose​(boolean autoClose)  
      void setDebug​(boolean debug)  
      void setVerbose​(boolean verbose)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Field Detail

      • debug

        protected boolean debug
      • verbose

        protected boolean verbose
      • autoClose

        protected boolean autoClose
      • countNewLineChars

        protected int countNewLineChars
      • lineNum

        protected int lineNum
      • next

        protected T next
      • reader

        protected java.io.BufferedReader reader
      • fileName

        protected java.lang.String fileName
      • line

        protected java.lang.String line
      • nextLine

        protected java.lang.String nextLine
      • fileSize

        protected long fileSize
    • Constructor Detail

      • FileIterator

        public FileIterator​(java.io.BufferedReader reader)
      • FileIterator

        public FileIterator​(java.lang.String fileName)
    • Method Detail

      • close

        public void close()
        Close file
      • countNewLineChars

        protected int countNewLineChars()
        Guess number of newline characters used (e.g. '\n' or '\r\n'
      • getFilePointer

        public long getFilePointer()
        Get position within file
      • getLine

        public java.lang.String getLine()
      • getLineNum

        public int getLineNum()
      • guessNewLineChars

        protected void guessNewLineChars()
        Guess number of newline characters used (e.g. '\n' or '\r\n' Make sure we return to the current read position
      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<T>
      • hasSeek

        public boolean hasSeek()
        Is 'seek' operation supported?
      • init

        protected void init​(java.lang.String fileName,
                            int inOffset)
        Initialize
        Parameters:
        fileName - : Can be null (no file is opened)
      • isDebug

        public boolean isDebug()
      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<T>
      • load

        public java.util.List<T> load()
        Load all elements from a file into a list
      • next

        public T next()
        Specified by:
        next in interface java.util.Iterator<T>
      • readLine

        protected java.lang.String readLine()
                                     throws java.io.IOException
        Read a line from reader
        Throws:
        java.io.IOException
      • readNext

        protected abstract T readNext()
        Read next element
      • ready

        protected boolean ready()
                         throws java.io.IOException
        Is reader ready? I.e. Can we read a line?
        Throws:
        java.io.IOException
      • remove

        public void remove()
        Specified by:
        remove in interface java.util.Iterator<T>
      • seek

        public void seek​(long pos)
                  throws java.io.IOException
        Seek to 'pos' (jump to byte number 'pos' in the file
        Throws:
        java.io.IOException
      • setAutoClose

        public void setAutoClose​(boolean autoClose)
      • setDebug

        public void setDebug​(boolean debug)
      • setVerbose

        public void setVerbose​(boolean verbose)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object