Package dev.aherscu.qa.testing.utils
Class FileUtilsExtensions
- java.lang.Object
-
- org.apache.commons.io.FileUtils
-
- dev.aherscu.qa.testing.utils.FileUtilsExtensions
-
public final class FileUtilsExtensions extends org.apache.commons.io.FileUtils
Provides encoding-safe file readers and writers.- Author:
- aherscu
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
append(File sourceFile, File targetFile)
Reads lines from source file and appends them into target file, checking whether the parent directory exists, and creating it if it does not exist.static File
file(Class<?> clazz, String name)
Constructs aFile
by specified name relative to specified class.static Reader
fileReader(File from)
Constructs aFileReader
usingStandardCharsets.UTF_8
.static Writer
fileWriter(File to)
Constructs aFileWriter
usingStandardCharsets.UTF_8
.static String[]
toSuffixes(String... extensions)
Converts an array of file extensions to suffixes for use with IOFileFilters.-
Methods inherited from class org.apache.commons.io.FileUtils
byteCountToDisplaySize, byteCountToDisplaySize, byteCountToDisplaySize, checksum, checksumCRC32, cleanDirectory, contentEquals, contentEqualsIgnoreEOL, convertFileCollectionToFileArray, copyDirectory, copyDirectory, copyDirectory, copyDirectory, copyDirectory, copyDirectoryToDirectory, copyFile, copyFile, copyFile, copyFile, copyFile, copyFileToDirectory, copyFileToDirectory, copyInputStreamToFile, copyToDirectory, copyToDirectory, copyToFile, copyURLToFile, copyURLToFile, createParentDirectories, current, delete, deleteDirectory, deleteQuietly, directoryContains, forceDelete, forceDeleteOnExit, forceMkdir, forceMkdirParent, getFile, getFile, getTempDirectory, getTempDirectoryPath, getUserDirectory, getUserDirectoryPath, isDirectory, isEmptyDirectory, isFileNewer, isFileNewer, isFileNewer, isFileNewer, isFileNewer, isFileNewer, isFileNewer, isFileNewer, isFileNewer, isFileNewer, isFileNewer, isFileNewer, isFileOlder, isFileOlder, isFileOlder, isFileOlder, isFileOlder, isFileOlder, isFileOlder, isFileOlder, isFileOlder, isFileOlder, isFileOlder, isFileOlder, isRegularFile, isSymlink, iterateFiles, iterateFiles, iterateFilesAndDirs, lastModified, lastModifiedFileTime, lastModifiedUnchecked, lineIterator, lineIterator, listFiles, listFiles, listFilesAndDirs, moveDirectory, moveDirectoryToDirectory, moveFile, moveFile, moveFileToDirectory, moveToDirectory, newOutputStream, openInputStream, openOutputStream, openOutputStream, readFileToByteArray, readFileToString, readFileToString, readFileToString, readLines, readLines, readLines, sizeOf, sizeOfAsBigInteger, sizeOfDirectory, sizeOfDirectoryAsBigInteger, streamFiles, toFile, toFiles, touch, toURLs, waitFor, write, write, write, write, write, write, writeByteArrayToFile, writeByteArrayToFile, writeByteArrayToFile, writeByteArrayToFile, writeLines, writeLines, writeLines, writeLines, writeLines, writeLines, writeLines, writeLines, writeStringToFile, writeStringToFile, writeStringToFile, writeStringToFile, writeStringToFile, writeStringToFile
-
-
-
-
Method Detail
-
append
public static void append(File sourceFile, File targetFile) throws IOException
Reads lines from source file and appends them into target file, checking whether the parent directory exists, and creating it if it does not exist.- Parameters:
sourceFile
- the source filetargetFile
- the target file- Throws:
IOException
- in case of an I/O error
-
file
public static File file(Class<?> clazz, String name)
Constructs aFile
by specified name relative to specified class.- Parameters:
clazz
- the class from which package to computename
- the name- Returns:
- the file refered by specified name relative to specified class
-
fileReader
public static Reader fileReader(File from) throws IOException
Constructs aFileReader
usingStandardCharsets.UTF_8
.- Parameters:
from
- the file from which to read- Returns:
- the reader
- Throws:
IOException
- in case of I/O failure
-
fileWriter
public static Writer fileWriter(File to) throws IOException
Constructs aFileWriter
usingStandardCharsets.UTF_8
.- Parameters:
to
- the file to which to write- Returns:
- the writer
- Throws:
IOException
- in case of I/O failure
-
-