Class BurnOnCloseFileIterator<T>
- java.lang.Object
-
- org.apache.jackrabbit.oak.commons.io.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 aCloseable
wrapper over aLineIterator
. Also has a transformer to transform the output. If the underlying file is provided then it deletes the file onclose()
. If there is a scope for lines in the file containing line break characters it should be ensured that the files is written withFileIOUtils.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)
-
-
-
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 interfacejava.util.Iterator<T>
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.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)
-
-