java. users will find similar utilities in MoreFiles and the
JDK's java. class.
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static class | |
| private static enum |
| Modifier and Type | Field and Description |
|---|---|
| private static final SuccessorsFunction |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static void | append(CharSequence
the character sequence to append from, File the destination file to, Charset the charset used to encode the output stream; see charset)StandardCharsets for
helpful predefined constants
Deprecated
Prefer
Appends a character sequence (such as a string) to a file using the given character set.
asCharSink(to, charset, FileWriteMode.APPEND).write(from). This
method is scheduled to be removed in October 2019.
|
| public static ByteSink | asByteSink(File file, FileWriteMode... modes)
Returns a new |
| public static ByteSource | |
| public static CharSink | asCharSink(File file, Charset charset, FileWriteMode... modes)
Returns a new |
| public static CharSource | asCharSource(File file, Charset charset)
Returns a new |
| public static void | copy(File
the source file from, OutputStream the output stream to)Copies all bytes from a file to an output stream. |
| public static void | |
| public static void | copy(File
the source file from, Charset the charset used to decode the input stream; see charset, Appendable StandardCharsets for
helpful predefined constantsthe appendable object to)
Deprecated
Prefer
Copies all characters from a file to an appendable object, using the given character set.
asCharSource(from, charset).copyTo(to).
|
| public static void | createParentDirs(File file)
Creates any necessary but nonexistent parent directories of the specified file. |
| public static File | Returns: the newly-created directory
Deprecated
For Android users, see the Data and File
Storage overview to select an appropriate temporary directory (perhaps
Atomically creates a new directory somewhere beneath the system's temporary directory (as
defined by the context.getCacheDir()), and create your own directory under that.
java.io.tmpdir system property), and returns its name.
|
| public static boolean | |
| public static Traverser | |
| public static String | getFileExtension(String fullName)
Returns the file extension for the given file name, or the empty string if the file has no extension. |
| public static String | Returns: The file name without its path or extension.The name of the file to trim the extension from. This can be either a fully
qualified file name (including a path) or just a file name. file)Returns the file name without its file extension or path. |
| public static HashCode | Returns: theHashCode of all of the bytes in the filethe file to read file, HashFunction the hash function to use to hash the data hashFunction)
Deprecated
Prefer
Computes the hash code of the asByteSource(file).hash(hashFunction).
file using hashFunction.
|
| public static Predicate | |
| public static Predicate | |
| public static MappedByteBuffer | Returns: a read-only buffer reflectingfilethe file to map file)Fully maps a file read-only in to memory as per |
| public static MappedByteBuffer | Returns: a buffer reflectingfilethe file to map file, FileChannel.the mode to use when mapping modefileFully maps a file in to memory as per |
| public static MappedByteBuffer | Returns: a buffer reflectingfilethe file to map file, FileChannel.the mode to use when mapping mode,fileMaps a file in to memory as per |
| private static MappedByteBuffer | |
| public static void | |
| public static BufferedReader | Returns: the buffered readerthe file to read from file, Charset the charset used to decode the input stream; see charset)StandardCharsets for
helpful predefined constantsReturns a buffered reader that reads from a file using the given character set. |
| public static BufferedWriter | Returns: the buffered writerthe file to write to file, Charset the charset used to encode the output stream; see charset)StandardCharsets for
helpful predefined constantsReturns a buffered writer that writes to a file using the given character set. |
| public static <T extends @Nullable Object> T | Returns: the result of the byte processorthe file to read file, ByteProcessor<T> the object to which the bytes of the file are passed. processor)
Deprecated
Prefer
Process the bytes of a file.
asByteSource(file).read(processor).
|
| public static String | Returns: the first line, or null if the file is emptythe file to read from file, Charset the charset used to decode the input stream; see charset)StandardCharsets for
helpful predefined constants
Deprecated
Prefer
Reads the first line from a file.
asCharSource(file, charset).readFirstLine().
|
| public static List | Returns: a mutableList containing all the linesthe file to read from file, Charset the charset used to decode the input stream; see charset)StandardCharsets for
helpful predefined constantsReads all of the lines from a file. |
| public static <T extends @Nullable Object> T | Returns: the output of processing the linesthe file to read from file, Charset the charset used to decode the input stream; see charset, LineProcessor<T> StandardCharsets for
helpful predefined constantsthe callback)LineProcessor to use to handle the lines
Deprecated
Prefer
Streams lines from a asCharSource(file, charset).readLines(callback).
File, stopping when our callback returns false, or we have read
all of the lines.
|
| public static String | simplifyPath(String pathname)
Returns the lexically cleaned form of the path name, usually (but not always) equivalent to the original. |
| public static byte[] | Returns: a byte array containing all the bytes from filethe file to read from file)Reads all bytes from a file into a byte array. |
| public static String | Returns: a string containing all the characters from the filethe file to read from file, Charset the charset used to decode the input stream; see charset)StandardCharsets for
helpful predefined constants
Deprecated
Prefer
Reads all characters from a file into a asCharSource(file, charset).read().
String, using the given character set.
|
| public static void | |
| public static void | |
| public static void | write(CharSequence
the character sequence to write from, File the destination file to, Charset the charset used to encode the output stream; see charset)StandardCharsets for
helpful predefined constants
Deprecated
Prefer
Writes a character sequence (such as a string) to a file using the given character set.
asCharSink(to, charset).write(from).
|