public final class IOHelper
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.util.List<java.nio.file.Path> |
collectDirectoryFiles(java.nio.file.Path start,
java.nio.file.FileVisitOption... options)
Collect all files in a directory.
|
static java.util.List<java.nio.file.Path> |
collectDirectoryFiles(java.nio.file.Path start,
java.util.function.Predicate<java.nio.file.Path> filter,
java.nio.file.FileVisitOption... options)
Collect all files in a directory.
|
static long |
copyStream(java.io.InputStream in,
java.io.OutputStream out)
Copy all data from an
InputStream to an OutputStream. |
static java.nio.file.Path |
createTempDirFromZIPResource(java.net.URL resource,
java.nio.file.Path dir,
java.lang.String prefix,
java.nio.file.attribute.FileAttribute<?>... attrs)
Create a temporary directory and initialize it by copying a ZIP resource's content.
|
static java.nio.file.Path |
createTempDirFromZIPResource(java.net.URL resource,
java.lang.String prefix,
java.nio.file.attribute.FileAttribute<?>... attrs)
Create a temporary directory and initialize it by copying a ZIP resource's content.
|
static java.nio.file.Path |
createTempFileFromResource(java.net.URL resource,
java.nio.file.Path dir,
java.lang.String prefix,
java.lang.String suffix,
java.nio.file.attribute.FileAttribute<?>... attrs)
Create a temporary file and initialize it by copying a resource's content.
|
static java.nio.file.Path |
createTempFileFromResource(java.net.URL resource,
java.lang.String prefix,
java.lang.String suffix,
java.nio.file.attribute.FileAttribute<?>... attrs)
Create a temporary file and initialize it by copying a resource's content.
|
static void |
deleteDirectoryTree(java.io.File directory)
Delete a directory and all it's included sub-directories/files.
|
static void |
deleteDirectoryTree(java.nio.file.Path directory)
Delete a directory and all it's included sub-directories/files.
|
static void |
deleteDirectoryTree(java.lang.String directory)
Delete a directory and all it's included sub-directories/files.
|
static byte[] |
readBytes(java.io.InputStream in)
Read all bytes from an
InputStream. |
static byte[] |
readBytes(java.io.InputStream in,
int limit)
Read up to a maximum number of bytes from an
InputStream. |
public static byte[] readBytes(java.io.InputStream in)
throws java.io.IOException
InputStream.in - The input stream to read from.java.io.IOException - if an I/O error occurs while reading data.public static byte[] readBytes(java.io.InputStream in,
int limit)
throws java.io.IOException
InputStream.in - The input stream to read from.limit - The maximum number of bytes to read.java.io.InterruptedIOException - if the read limit has been reached.java.io.IOException - if an I/O error occurs while reading data.public static long copyStream(java.io.InputStream in,
java.io.OutputStream out)
throws java.io.IOException
InputStream to an OutputStream.in - The input stream to read from.out - The output stream to write to.java.io.IOException - if an I/O error occurs while reading or writing data.public static java.util.List<java.nio.file.Path> collectDirectoryFiles(java.nio.file.Path start,
java.nio.file.FileVisitOption... options)
throws java.io.IOException
start - The directory path to scan.options - The scan options.java.io.IOException - if an I/O error occurs.public static java.util.List<java.nio.file.Path> collectDirectoryFiles(java.nio.file.Path start,
java.util.function.Predicate<java.nio.file.Path> filter,
java.nio.file.FileVisitOption... options)
throws java.io.IOException
start - The directory path to scan.filter - The filter to apply to the scan result.options - The scan options.java.io.IOException - if an I/O error occurs.public static void deleteDirectoryTree(java.lang.String directory)
throws java.io.IOException
directory - The directory to delete.java.io.IOException - if an I/O error occurs while deleting the directory tree.public static void deleteDirectoryTree(java.io.File directory)
throws java.io.IOException
directory - The directory to delete.java.io.IOException - if an I/O error occurs while deleting the directory tree.public static void deleteDirectoryTree(java.nio.file.Path directory)
throws java.io.IOException
directory - The directory to delete.java.io.IOException - if an I/O error occurs while deleting the directory tree.public static java.nio.file.Path createTempFileFromResource(java.net.URL resource,
@Nullable
java.lang.String prefix,
@Nullable
java.lang.String suffix,
java.nio.file.attribute.FileAttribute<?>... attrs)
throws java.io.IOException
resource - The resource to use for file initialization.prefix - The prefix to use for temp file creation (may be null).suffix - The suffix to use for temp file creation (may be null).attrs - The file attributes to use for temp file creation.java.io.IOException - if an I/O error occurs.Files.createTempFile(String, String, FileAttribute...)public static java.nio.file.Path createTempFileFromResource(java.net.URL resource,
java.nio.file.Path dir,
@Nullable
java.lang.String prefix,
@Nullable
java.lang.String suffix,
java.nio.file.attribute.FileAttribute<?>... attrs)
throws java.io.IOException
resource - The resource to use for file initialization.dir - The directory to use for temp file creation.prefix - The prefix to use for temp file creation (may be null).suffix - The suffix to use for temp file creation (may be null).attrs - The file attributes to use for temp file creation.java.io.IOException - if an I/O error occurs.Files.createTempFile(Path, String, String, FileAttribute...)public static java.nio.file.Path createTempDirFromZIPResource(java.net.URL resource,
@Nullable
java.lang.String prefix,
java.nio.file.attribute.FileAttribute<?>... attrs)
throws java.io.IOException
resource - The resource to use for directory initialization.prefix - The prefix to use for temp dir creation (may be null).attrs - The file attributes to use for temp dir creation.java.io.IOException - if an I/O error occurs.Files.createTempDirectory(String, FileAttribute...)public static java.nio.file.Path createTempDirFromZIPResource(java.net.URL resource,
java.nio.file.Path dir,
@Nullable
java.lang.String prefix,
java.nio.file.attribute.FileAttribute<?>... attrs)
throws java.io.IOException
resource - The resource to use for directory initialization.dir - The directory to use for temp dir creation.prefix - The prefix to use for temp dir creation (may be null).attrs - The file attributes to use for temp dir creation.java.io.IOException - if an I/O error occurs.Files.createTempDirectory(Path, String, FileAttribute...)