public final class FileIOUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
FileIOUtils.BurnOnCloseFileIterator<T>
Implements a
Closeable wrapper over a LineIterator. |
static class |
FileIOUtils.FileLineDifferenceIterator
FileLineDifferenceIterator class which iterates over the difference of 2 files line by line.
|
static class |
FileIOUtils.TransformingComparator
Decorates the given comparator and applies the function before delegating to the decorated
comparator.
|
| Modifier and Type | Field and Description |
|---|---|
static Comparator<String> |
lexComparator |
| Modifier and Type | Method and Description |
|---|---|
static void |
append(List<File> files,
File appendTo,
boolean delete)
Appends the contents of the list of files to the given file and deletes the files
if the delete flag is enabled.
|
static File |
copy(InputStream stream)
Copies an input stream to a file.
|
static Comparator<String> |
lineBreakAwareComparator(Comparator<String> delegate)
Composing iterator which unescapes for line breaks and delegates to the given comparator.
|
static void |
merge(List<File> files,
File output)
Merges a list of files after sorting with the
lexComparator. |
static void |
merge(List<File> files,
File output,
Comparator<String> comparator)
Merges a list of files after sorting with the given comparator.
|
static Set<String> |
readStringsAsSet(InputStream stream,
boolean unescape)
Reads strings from the given stream into a set and optionally unescaping for line breaks.
|
static void |
sort(File file)
Sorts the given file externally using the
lexComparator and removes duplicates. |
static void |
sort(File file,
Comparator<String> comparator)
Sorts the given file externally with the given comparator and removes duplicates.
|
static void |
writeAsLine(BufferedWriter writer,
String str,
boolean escape)
Writes a string as a new line into the given buffered writer and optionally
escapes the line for line breaks.
|
static int |
writeStrings(Iterator<String> iterator,
File f,
boolean escape)
Writes string from the given iterator to the given file and optionally
escape the written strings for line breaks.
|
static int |
writeStrings(Iterator<String> iterator,
File f,
boolean escape,
org.slf4j.Logger logger,
String message)
Writes string from the given iterator to the given file and optionally
escape the written strings for line breaks.
|
public static final Comparator<String> lexComparator
public static void sort(File file) throws IOException
lexComparator and removes duplicates.file - file whose contents needs to be sortedIOExceptionpublic static void sort(File file, Comparator<String> comparator) throws IOException
file - file whose contents needs to be sortedcomparator - to compareIOExceptionpublic static void merge(List<File> files, File output) throws IOException
lexComparator.files - files to mergeoutput - merge output fileIOExceptionpublic static void merge(List<File> files, File output, Comparator<String> comparator) throws IOException
files - files to mergeoutput - merge output fileIOExceptionpublic static File copy(InputStream stream) throws IOException
stream - steam to copyIOExceptionpublic static void append(List<File> files, File appendTo, boolean delete) throws IOException
writeAsLine(BufferedWriter, String, boolean)
with true to escape line break characters.files - appendTo - IOExceptionpublic static void writeAsLine(BufferedWriter writer, String str, boolean escape) throws IOException
writer - to write the stringstr - the string to writeescape - whether to escape string for line breaksIOExceptionpublic static int writeStrings(Iterator<String> iterator, File f, boolean escape) throws IOException
iterator - the source of the stringsf - file to write toescape - whether to escape for line breaksIOExceptionpublic static int writeStrings(Iterator<String> iterator, File f, boolean escape, @Nullable org.slf4j.Logger logger, @Nullable String message) throws IOException
iterator - the source of the stringsf - file to write toescape - escape whether to escape for line breakslogger - logger to log progressmessage - message to logIOExceptionpublic static Set<String> readStringsAsSet(InputStream stream, boolean unescape) throws IOException
stream - the source of the stringsunescape - whether to unescape for line breaksIOExceptionpublic static Comparator<String> lineBreakAwareComparator(Comparator<String> delegate)
delegate - the actual comparison iteratorCopyright © 2012–2017 The Apache Software Foundation. All rights reserved.