public final class FileUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
attemptToDeleteRecursively(File file)
Similar to
File.delete(), but clears and deletes directory trees recursively. |
static void |
deleteRecursively(File file)
Deletes the given regular file, or clears and deletes the given directory recursively.
|
static ProducerWhichThrows<ByteArrayInputStream,IOException> |
opener(byte[] data) |
static ProducerWhichThrows<FileInputStream,IOException> |
opener(File file) |
static <EX extends Throwable> |
processContent(File file,
Charset charset,
ConsumerWhichThrows<? super Reader,? extends EX> processor)
Opens the named file, lets the processor read text from it, and closes the file.
|
static <EX extends Throwable> |
processContent(Reader reader,
ConsumerWhichThrows<? super Reader,? extends EX> processor)
Passes the given reader to the processor, and then closes the file.
|
static void |
rename(File oldFile,
File newFile) |
public static boolean attemptToDeleteRecursively(File file)
File.delete(), but clears and deletes directory trees recursively.file - The regular file or directory to deletepublic static void deleteRecursively(File file) throws IOException
IOException - The file could not be deletedpublic static void rename(File oldFile, File newFile) throws IOException
IOException - Renaming failedFile.renameTo(File)public static <EX extends Throwable> void processContent(File file, Charset charset, ConsumerWhichThrows<? super Reader,? extends EX> processor) throws IOException, EX extends Throwable
charset - The charset to be used for readingEX - The throwable that the processor may throwIOExceptionEX extends Throwablepublic static <EX extends Throwable> void processContent(Reader reader, ConsumerWhichThrows<? super Reader,? extends EX> processor) throws IOException, EX extends Throwable
EX - The throwable that the processor may throwIOExceptionEX extends Throwablepublic static ProducerWhichThrows<FileInputStream,IOException> opener(File file)
FileInputStreams for the given filepublic static ProducerWhichThrows<ByteArrayInputStream,IOException> opener(byte[] data)
ByteArrayInputStreams for the given dataCopyright © 2018 Arno Unkrig. All rights reserved.