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