Class BurnOnCloseFileIterator<T>

  • Type Parameters:
    T - the type of elements in the iterator
    All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.util.Iterator<T>

    public class BurnOnCloseFileIterator<T>
    extends java.lang.Object
    implements java.io.Closeable, java.util.Iterator<T>
    Implements a Closeable wrapper over a LineIterator. Also has a transformer to transform the output. If the underlying file is provided then it deletes the file on close(). If there is a scope for lines in the file containing line break characters it should be ensured that the files is written with FileIOUtils.writeAsLine(BufferedWriter, String, boolean) with true to escape line break characters and should be properly unescaped on read. A custom transformer can also be provided to unescape.
    • Constructor Summary

      Constructors 
      Constructor Description
      BurnOnCloseFileIterator​(java.util.Iterator<java.lang.String> iterator, java.io.File backingFile, java.util.function.Function<java.lang.String,​T> transformer)  
      BurnOnCloseFileIterator​(java.util.Iterator<java.lang.String> iterator, java.util.function.Function<java.lang.String,​T> transformer)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      boolean hasNext()  
      T next()  
      static BurnOnCloseFileIterator<java.lang.String> wrap​(java.util.Iterator<java.lang.String> iter)  
      static BurnOnCloseFileIterator<java.lang.String> wrap​(java.util.Iterator<java.lang.String> iter, java.io.File backingFile)  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining, remove
    • Constructor Detail

      • BurnOnCloseFileIterator

        public BurnOnCloseFileIterator​(java.util.Iterator<java.lang.String> iterator,
                                       java.util.function.Function<java.lang.String,​T> transformer)
      • BurnOnCloseFileIterator

        public BurnOnCloseFileIterator​(java.util.Iterator<java.lang.String> iterator,
                                       java.io.File backingFile,
                                       java.util.function.Function<java.lang.String,​T> transformer)
    • Method Detail

      • hasNext

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

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

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • wrap

        public static BurnOnCloseFileIterator<java.lang.String> wrap​(java.util.Iterator<java.lang.String> iter)
      • wrap

        public static BurnOnCloseFileIterator<java.lang.String> wrap​(java.util.Iterator<java.lang.String> iter,
                                                                     java.io.File backingFile)