In most cases, the methods defined here will delegate to the associated file system provider to perform the file operations.
Modifier and Type | Class and Description |
---|---|
private static class | |
private static class |
Modifier and Type | Field and Description |
---|---|
private static final int | |
private static final Set | |
private static final JavaLangAccess |
Access | Constructor and Description |
---|---|
private |
Modifier and Type | Method and Description |
---|---|
private static Runnable | asUncheckedRunnable(Closeable c)
Convert a Closeable to a Runnable by converting checked IOException to UncheckedIOException |
public static Path | Returns: the path to the target filethe path to the file to copy source, Path the path to the target file (may be associated with a different
provider to the source path) target, CopyOption... options specifying how the copy should be done options)Copy a file to a target file. |
public static long | Returns: the number of bytes read or writtenthe input stream to read from in, Path the path to the file target, CopyOption... options specifying how the copy should be done options)Copies all bytes from an input stream to a file. |
public static long | Returns: the number of bytes read or writtenthe path to the file source, OutputStream the output stream to write to out)Copies all bytes from a file to an output stream. |
private static void | createAndCheckIsDirectory(Path dir, FileAttribute<?>... attrs)
Used by createDirectories to attempt to create a directory. |
private static Stream | |
public static Path | Returns: the directorythe directory to create dir, FileAttribute<?>... an optional list of file attributes to set atomically when
creating the directory attrs)Creates a directory by creating all nonexistent parent directories first. |
public static Path | Returns: the directorythe directory to create dir, FileAttribute<?>... an optional list of file attributes to set atomically when
creating the directory attrs)Creates a new directory. |
public static Path | Returns: the filethe path to the file to create path, FileAttribute<?>... an optional list of file attributes to set atomically when
creating the file attrs)Creates a new and empty file, failing if the file already exists. |
private static Stream | |
public static Path | Returns: the path to the link (directory entry)the link (directory entry) to create link, Path a path to an existing file existing)Creates a new link (directory entry) for an existing file (optional operation). |
public static Path | Returns: the path to the symbolic linkthe path of the symbolic link to create link, Path the target of the symbolic link target, FileAttribute<?>... the array of attributes to set atomically when creating the
symbolic link attrs)Creates a symbolic link to a target (optional operation). |
public static Path | Returns: the path to the newly created directory that did not exist before this method was invokedthe path to directory in which to create the directory dir, String the prefix string to be used in generating the directory's name;
may be prefix, FileAttribute<?>... null an optional list of file attributes to set atomically when
creating the directory attrs)Creates a new directory in the specified directory, using the given prefix to generate its name. |
public static Path | Returns: the path to the newly created directory that did not exist before this method was invokedthe prefix string to be used in generating the directory's name;
may be prefix, FileAttribute<?>... null an optional list of file attributes to set atomically when
creating the directory attrs)Creates a new directory in the default temporary-file directory, using the given prefix to generate its name. |
public static Path | Returns: the path to the newly created file that did not exist before this method was invokedthe path to directory in which to create the file dir, String the prefix string to be used in generating the file's name;
may be prefix, String null the suffix string to be used in generating the file's name;
may be suffix, FileAttribute<?>... null , in which case ".tmp " is usedan optional list of file attributes to set atomically when
creating the file attrs)Creates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name. |
public static Path | Returns: the path to the newly created file that did not exist before this method was invokedthe prefix string to be used in generating the file's name;
may be prefix, String null the suffix string to be used in generating the file's name;
may be suffix, FileAttribute<?>... null , in which case ".tmp " is usedan optional list of file attributes to set atomically when
creating the file attrs)Creates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name. |
public static void | |
public static boolean | Returns: true if the file was deleted by this method; false if the file could not be deleted because it did not
existthe path to the file to delete path)Deletes a file if it exists. |
public static boolean | Returns: true if the file exists; false if the file does
not exist or its existence cannot be determined.the path to the file to test path, LinkOption... options indicating how symbolic links are handled options)Tests whether a file exists. |
public static Stream | find(Path
the starting file start, int the maximum number of directory levels to search maxDepth, BiPredicate<Path, BasicFileAttributes> the function used to decide whether a file should be included
in the returned stream matcher, FileVisitOption... options to configure the traversal options)Returns a |
private static boolean | |
public static Object | Returns: the attribute valuethe path to the file path, String the attribute to read attribute, LinkOption... options indicating how symbolic links are handled options)Reads the value of a file attribute. |
public static < The V extends FileAttributeView> VFileAttributeView type | Returns: a file attribute view of the specified type, ornull if
the attribute view type is not availablethe path to the file path, Class<V> the type, LinkOption... Class object corresponding to the file attribute viewoptions indicating how symbolic links are handled options)Returns a file attribute view of a given type. |
public static FileStore | Returns: the file store where the file is storedthe path to the file path)Returns the |
public static FileTime | Returns: aFileTime representing the time the file was last
modified, or an implementation specific default when a time
stamp to indicate the time of last modification is not supported
by the file systemthe path to the file path, LinkOption... options indicating how symbolic links are handled options)Returns a file's last modified time. |
public static UserPrincipal | Returns: A user principal representing the owner of the fileThe path to the file path, LinkOption... options indicating how symbolic links are handled options)Returns the owner of a file. |
public static Set | Returns: the file permissionsthe path to the file path, LinkOption... options indicating how symbolic links are handled options)Returns a file's POSIX file permissions. |
private static boolean | isAccessible(Path path, AccessMode... modes)
Used by isReadable, isWritable, isExecutable to test access to a file. |
public static boolean | Returns: true if the file is a directory; false if
the file does not exist, is not a directory, or it cannot
be determined if the file is a directory or not.the path to the file to test path, LinkOption... options indicating how symbolic links are handled options)Tests whether a file is a directory. |
public static boolean | Returns: true if the file exists and is executable; false
if the file does not exist, execute access would be denied because
the Java virtual machine has insufficient privileges, or access
cannot be determinedthe path to the file to check path)Tests whether a file is executable. |
public static boolean | |
public static boolean | Returns: true if the file exists and is readable; false
if the file does not exist, read access would be denied because
the Java virtual machine has insufficient privileges, or access
cannot be determinedthe path to the file to check path)Tests whether a file is readable. |
public static boolean | Returns: true if the file is a regular file; false if
the file does not exist, is not a regular file, or it
cannot be determined if the file is a regular file or not.the path to the file path, LinkOption... options indicating how symbolic links are handled options)Tests whether a file is a regular file with opaque content. |
public static boolean | Returns: true if, and only if, the two paths locate the same fileone path to the file path, Path the other path path2)Tests if two paths locate the same file. |
public static boolean | Returns: true if the file is a symbolic link; false if
the file does not exist, is not a symbolic link, or it cannot
be determined if the file is a symbolic link or not.The path to the file path)Tests whether a file is a symbolic link. |
public static boolean | Returns: true if the file exists and is writable; false
if the file does not exist, write access would be denied because
the Java virtual machine has insufficient privileges, or access
cannot be determinedthe path to the file to check path)Tests whether a file is writable. |
public static Stream | |
public static Stream | |
public static Stream | |
public static long | |
public static Path | Returns: the path to the target filethe path to the file to move source, Path the path to the target file (may be associated with a different
provider to the source path) target, CopyOption... options specifying how the move should be done options)Move or rename a file to a target file. |
public static BufferedReader | Returns: a new buffered reader, with default buffer size, to read text from the filethe path to the file path, Charset the charset to use for decoding cs)Opens a file for reading, returning a |
public static BufferedReader | Returns: a new buffered reader, with default buffer size, to read text from the filethe path to the file path)Opens a file for reading, returning a |
public static BufferedWriter | Returns: a new buffered writer, with default buffer size, to write text to the filethe path to the file path, Charset the charset to use for encoding cs, OpenOption... options specifying how the file is opened options)Opens or creates a file for writing, returning a |
public static BufferedWriter | Returns: a new buffered writer, with default buffer size, to write text to the filethe path to the file path, OpenOption... options specifying how the file is opened options)Opens or creates a file for writing, returning a |
public static SeekableByteChannel | Returns: a new seekable byte channelthe path to the file to open or create path, Set<? extends OpenOption> options specifying how the file is opened options, FileAttribute<?>... an optional list of file attributes to set atomically when
creating the file attrs)Opens or creates a file, returning a seekable byte channel to access the file. |
public static SeekableByteChannel | Returns: a new seekable byte channelthe path to the file to open or create path, OpenOption... options specifying how the file is opened options)Opens or creates a file, returning a seekable byte channel to access the file. |
public static DirectoryStream | Returns: a new and openDirectoryStream objectthe path to the directory dir)Opens a directory, returning a |
public static DirectoryStream | Returns: a new and openDirectoryStream objectthe path to the directory dir, String the glob pattern glob)Opens a directory, returning a |
public static DirectoryStream | Returns: a new and openDirectoryStream objectthe path to the directory dir, DirectoryStream.the directory stream filter filterOpens a directory, returning a |
public static InputStream | Returns: a new input streamthe path to the file to open path, OpenOption... options specifying how the file is opened options)Opens a file, returning an input stream to read from the file. |
public static OutputStream | Returns: a new output streamthe path to the file to open or create path, OpenOption... options specifying how the file is opened options)Opens or creates a file, returning an output stream that may be used to write bytes to the file. |
public static boolean | Returns: true if the file does not exist; false if the
file exists or its existence cannot be determinedthe path to the file to test path, LinkOption... options indicating how symbolic links are handled options)Tests whether the file located by this path does not exist. |
public static String | Returns: The content type of the file, ornull if the content
type cannot be determinedthe path to the file to probe path)Probes the content type of a file. |
private static FileSystemProvider | |
private static byte[] | Returns: a byte array containing the bytes read from the filethe input stream to read from source, int the initial size of the byte array to allocate initialSize)Reads all the bytes from an input stream. |
public static byte[] | Returns: a byte array containing the bytes read from the filethe path to the file path)Reads all the bytes from a file. |
public static List | Returns: the lines from the file as aList ; whether the List is modifiable or not is implementation dependent and
therefore not specifiedthe path to the file path, Charset the charset to use for decoding cs)Read all lines from a file. |
public static List | Returns: the lines from the file as aList ; whether the List is modifiable or not is implementation dependent and
therefore not specifiedthe path to the file path)Read all lines from a file. |
public static < The A extends BasicFileAttributes> ABasicFileAttributes type | Returns: the file attributesthe path to the file path, Class<A> the type, LinkOption... Class of the file attributes required
to readoptions indicating how symbolic links are handled options)Reads a file's attributes as a bulk operation. |
public static Map | Returns: a map of the attributes returned; The map's keys are the attribute names, its values are the attribute valuesthe path to the file path, String the attributes to read attributes, LinkOption... options indicating how symbolic links are handled options)Reads a set of file attributes as a bulk operation. |
public static String | Returns: a String containing the content read from the filethe path to the file path)Reads all content from a file into a string, decoding from bytes to characters
using the |
public static String | Returns: a String containing the content read from the filethe path to the file path, Charset the charset to use for decoding cs)Reads all characters from a file into a string, decoding from bytes to characters using the specified charset. |
public static Path | Returns: aPath object representing the target of the linkthe path to the symbolic link link)Reads the target of a symbolic link (optional operation). |
public static Path | Returns: the given paththe path to the file path, String the attribute to set attribute, Object the attribute value value, LinkOption... options indicating how symbolic links are handled options)Sets the value of a file attribute. |
public static Path | Returns: the given paththe path to the file path, FileTime the new last modified time time)Updates a file's last modified time attribute. |
public static Path | Returns: The given pathThe path to the file path, UserPrincipal The new file owner owner)Updates the file owner. |
public static Path | Returns: The given pathThe path to the file path, Set<PosixFilePermission> The new set of permissions perms)Sets a file's POSIX permissions. |
public static long | |
public static Stream | walk(Path
the starting file start, int the maximum number of directory levels to visit maxDepth, FileVisitOption... options to configure the traversal options)Returns a |
public static Stream | walk(Path
the starting file start, FileVisitOption... options to configure the traversal options)Returns a |
public static Path | Returns: the starting filethe starting file start, Set<FileVisitOption> options to configure the traversal options, int the maximum number of directory levels to visit maxDepth, FileVisitor<? super Path> the file visitor to invoke for each file visitor)Walks a file tree. |
public static Path | Returns: the starting filethe starting file start, FileVisitor<? super Path> the file visitor to invoke for each file visitor)Walks a file tree. |
public static Path | Returns: the paththe path to the file path, byte[] the byte array with the bytes to write bytes, OpenOption... options specifying how the file is opened options)Writes bytes to a file. |
public static Path | Returns: the paththe path to the file path, Iterable<? extends CharSequence> an object to iterate over the char sequences lines, Charset the charset to use for encoding cs, OpenOption... options specifying how the file is opened options)Write lines of text to a file. |
public static Path | Returns: the paththe path to the file path, Iterable<? extends CharSequence> an object to iterate over the char sequences lines, OpenOption... options specifying how the file is opened options)Write lines of text to a file. |
public static Path | Returns: the paththe path to the file path, CharSequence the CharSequence to be written csq, OpenOption... options specifying how the file is opened options)Write a CharSequence to a file. |
public static Path | Returns: the paththe path to the file path, CharSequence the CharSequence to be written csq, Charset the charset to use for encoding cs, OpenOption... options specifying how the file is opened options)Write a CharSequence to a file. |