public class FileUtils extends Object
Modifier and Type | Field and Description |
---|---|
static int |
BUFFER_SIZE |
Constructor and Description |
---|
FileUtils() |
Modifier and Type | Method and Description |
---|---|
static long |
copy(Octopus octopus,
InputStream in,
Path target,
CopyOption... options)
Copies all bytes from an input stream to a file.
|
static long |
copy(Octopus octopus,
Path source,
OutputStream out)
Copies all bytes from a file to an output stream.
|
static BufferedReader |
newBufferedReader(Octopus octopus,
Path path,
Charset cs)
Opens a file for reading, returning a BufferedReader that may be used to
read text from the file in an efficient manner.
|
static BufferedWriter |
newBufferedWriter(Octopus octopus,
Path path,
Charset cs,
OpenOption... options)
Opens or creates a file for writing, returning a BufferedWriter that may
be used to write text to the file in an efficient manner.
|
static byte[] |
readAllBytes(Octopus octopus,
Path path)
Read all the bytes from a file.
|
static List<String> |
readAllLines(Octopus octopus,
Path path,
Charset cs)
Read all lines from a file.
|
private static FileVisitResult |
walk(Octopus octopus,
Path path,
FileAttributes attributes,
boolean followLinks,
int maxDepth,
FileVisitor visitor) |
static Path |
walkFileTree(Octopus octopus,
Path start,
boolean followLinks,
int maxDepth,
FileVisitor visitor)
Walks a file tree.
|
static Path |
walkFileTree(Octopus octopus,
Path start,
FileVisitor visitor)
Walks a file tree.
|
static Path |
write(Octopus octopus,
Path path,
byte[] bytes,
OpenOption... options)
Writes bytes to a file.
|
static Path |
write(Octopus octopus,
Path path,
Iterable<? extends CharSequence> lines,
Charset cs,
OpenOption... options)
Write lines of text to a file.
|
public static final int BUFFER_SIZE
public static long copy(Octopus octopus, InputStream in, Path target, CopyOption... options) throws OctopusException
OctopusException
- if an I/O error occurs when reading or writingFileAlreadyExistsException
- if the target file exists but cannot be replaced because the
REPLACE_EXISTING
option is not specified (optional
specific exception)DirectoryNotEmptyException
- the REPLACE_EXISTING
option is specified but the file
cannot be replaced because it is a non-empty directory
(optional specific exception) *UnsupportedOperationException
- if options
contains a copy option that is not
supportedpublic static long copy(Octopus octopus, Path source, OutputStream out) throws OctopusException
OctopusException
- if and I/O error occurs while reading or writingpublic static BufferedReader newBufferedReader(Octopus octopus, Path path, Charset cs) throws OctopusException
OctopusException
public static BufferedWriter newBufferedWriter(Octopus octopus, Path path, Charset cs, OpenOption... options) throws OctopusException
OctopusException
public static byte[] readAllBytes(Octopus octopus, Path path) throws OctopusException
OctopusException
public static List<String> readAllLines(Octopus octopus, Path path, Charset cs) throws OctopusException
OctopusException
public static Path write(Octopus octopus, Path path, byte[] bytes, OpenOption... options) throws OctopusException
OctopusException
public static Path write(Octopus octopus, Path path, Iterable<? extends CharSequence> lines, Charset cs, OpenOption... options) throws OctopusException
OctopusException
public static Path walkFileTree(Octopus octopus, Path start, FileVisitor visitor) throws OctopusException
OctopusException
public static Path walkFileTree(Octopus octopus, Path start, boolean followLinks, int maxDepth, FileVisitor visitor) throws OctopusException
OctopusException
private static FileVisitResult walk(Octopus octopus, Path path, FileAttributes attributes, boolean followLinks, int maxDepth, FileVisitor visitor) throws OctopusException
OctopusException