@Immutable public final class SimpleFileIO extends Object
FileOperations class or the instance based
FileOperationManager class.| Modifier and Type | Method and Description |
|---|---|
static byte[] |
getAllFileBytes(File aFile)
Get the content of the file as a byte array.
|
static ICommonsList<String> |
getAllFileLines(File aFile,
Charset aCharset)
Get the content of the passed file as a list of lines, whereas each line
does not contain a separator.
|
static String |
getFileAsString(File aFile,
Charset aCharset)
Get the content of the passed file as a string using the system line
separator.
|
static void |
readFileLines(File aFile,
Charset aCharset,
Consumer<String> aConsumer)
Get the content of the passed file as a list of lines, whereas each line
does not contain a separator.
|
static void |
readFileLines(File aFile,
Charset aCharset,
List<String> aTargetList)
Get the content of the passed file as a list of lines, whereas each line
does not contain a separator.
|
static ESuccess |
writeFile(File aFile,
byte[] aContent) |
static ESuccess |
writeFile(File aFile,
byte[] aContent,
int nOffset,
int nLength) |
static ESuccess |
writeFile(File aFile,
String sContent,
Charset aCharset) |
@Nullable public static byte[] getAllFileBytes(@Nullable File aFile)
aFile - The file to read. May be null.null if the passed file is null or if the
passed file does not exist.@Nullable public static String getFileAsString(@Nullable File aFile, @Nonnull Charset aCharset)
aFile - The file to read. May be null.aCharset - The character set to use. May not be null.null if the file does not exist, the content
otherwise.@Nullable public static ICommonsList<String> getAllFileLines(@Nullable File aFile, @Nonnull Charset aCharset)
aFile - The file to read. May be null.aCharset - The character set to use. May not be null.null if the file does not exist, the content
otherwise.public static void readFileLines(@Nullable File aFile, @Nonnull Charset aCharset, @Nonnull List<String> aTargetList)
aFile - The file to read. May be null.aCharset - The character set to use. May not be null.aTargetList - The target list to be filled. May not be null.public static void readFileLines(@Nullable File aFile, @Nonnull Charset aCharset, @Nonnull Consumer<String> aConsumer)
aFile - The file to read. May be null.aCharset - The character set to use. May not be null.aConsumer - The consumer to be invoked for each line. May not be
null.@Nonnull public static ESuccess writeFile(@Nonnull File aFile, @Nonnull byte[] aContent, @Nonnegative int nOffset, @Nonnegative int nLength)
Copyright © 2014–2017 Philip Helger. All rights reserved.