| Package | Description |
|---|---|
| java.io |
Provides for system input and output through data streams, serialization and the file system.
|
| java.nio.channels |
Defines channels, which represent connections to entities that are capable of performing I/O operations, such as files and sockets; defines selectors, for multiplexed, non-blocking I/O operations.
|
| java.nio.file |
Defines interfaces and classes for the Java virtual machine to access files, file attributes, and file systems.
|
| java.nio.file.spi |
Service-provider classes for the
java.nio.file package.
|
| java.util |
Contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator, and a bit array).
|
| Modifier and Type | Method and Description |
|---|---|
Path |
File.toPath()
Returns a
java.nio.file.Path object constructed from the this abstract path.
|
| Modifier and Type | Method and Description |
|---|---|
static FileChannel |
FileChannel.open(Path
Opens or creates a file, returning a file channel to access the file.
|
static AsynchronousFileChannel |
AsynchronousFileChannel.open(Path
Opens or creates a file for reading and/or writing, returning an asynchronous file channel to access the file.
|
static AsynchronousFileChannel |
AsynchronousFileChannel.open(Path
Opens or creates a file for reading and/or writing, returning an asynchronous file channel to access the file.
|
static FileChannel |
FileChannel.open(Path
Opens or creates a file, returning a file channel to access the file.
|
| Modifier and Type | Field and Description |
|---|---|
static WatchEvent |
StandardWatchEventKinds.ENTRY_CREATE
Directory entry created.
|
static WatchEvent |
StandardWatchEventKinds.ENTRY_DELETE
Directory entry deleted.
|
static WatchEvent |
StandardWatchEventKinds.ENTRY_MODIFY
Directory entry modified.
|
| Modifier and Type | Method and Description |
|---|---|
static Path |
Files.copy(Path
Copy a file to a target file.
|
static Path |
Files.createDirectories(Path
Creates a directory by creating all nonexistent parent directories first.
|
static Path |
Files.createDirectory(Path
Creates a new directory.
|
static Path |
Files.createFile(Path
Creates a new and empty file, failing if the file already exists.
|
static Path |
Files.createLink(Path
Creates a new link (directory entry) for an existing file
(optional operation).
|
static Path |
Files.createSymbolicLink(Path
Creates a symbolic link to a target
(optional operation).
|
static Path |
Files.createTempDirectory(Path
Creates a new directory in the specified directory, using the given prefix to generate its name.
|
static Path |
Files.createTempDirectory(String
Creates a new directory in the default temporary-file directory, using the given prefix to generate its name.
|
static Path |
Files.createTempFile(Path
Creates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name.
|
static Path |
Files.createTempFile(String
Creates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name.
|
static Path |
Paths.get(String
Converts a path string, or a sequence of strings that when joined form a path string, to a
Path.
|
static Path |
Paths.get(URI
Converts the given URI to a
Path object.
|
Path |
Path.getFileName()
Returns the name of the file or directory denoted by this path as a
Path object.
|
Path |
Path.getName(int index)
Returns a name element of this path as a
Path object.
|
Path |
Path.getParent()
Returns the
parent path, or
null if this path does not have a parent.
|
abstract Path |
FileSystem.getPath(String
Converts a path string, or a sequence of strings that when joined form a path string, to a
Path.
|
Path |
Path.getRoot()
Returns the root component of this path as a
Path object, or
null if this path does not have a root component.
|
static Path |
Files.move(Path
Move or rename a file to a target file.
|
Path |
Path.normalize()
Returns a path that is this path with redundant name elements eliminated.
|
static Path |
Files.readSymbolicLink(Path
Reads the target of a symbolic link
(optional operation).
|
Path |
Path.relativize(Path
Constructs a relative path between this path and a given path.
|
Path |
Path.resolve(Path
Resolve the given path against this path.
|
Path |
Path.resolve(String
Converts a given path string to a
Path and resolves it against this
Path in exactly the manner specified by the
resolve method.
|
Path |
Path.resolveSibling(Path
Resolves the given path against this path's
parent path.
|
Path |
Path.resolveSibling(String
Converts a given path string to a
Path and resolves it against this path's
parent path in exactly the manner specified by the
resolveSibling method.
|
static Path |
Files.setAttribute(Path
Sets the value of a file attribute.
|
static Path |
Files.setLastModifiedTime(Path
Updates a file's last modified time attribute.
|
static Path |
Files.setOwner(Path
Updates the file owner.
|
static Path |
Files.setPosixFilePermissions(Path
Sets a file's POSIX permissions.
|
Path |
Path.subpath(int beginIndex, int endIndex)
Returns a relative
Path that is a subsequence of the name elements of this path.
|
Path |
Path.toAbsolutePath()
Returns a
Path object representing the absolute path of this path.
|
Path |
Path.toRealPath(LinkOption
Returns the
real path of an existing file.
|
static Path |
Files.walkFileTree(Path
Walks a file tree.
|
static Path |
Files.walkFileTree(Path
Walks a file tree.
|
static Path |
Files.write(Path
Writes bytes to a file.
|
static Path |
Files.write(Path
Write lines of text to a file.
|
static Path |
Files.write(Path
Write lines of text to a file.
|
| Modifier and Type | Method and Description |
|---|---|
static Stream |
Files.find(Path
Return a
Stream that is lazily populated with
Path by searching for files in a file tree rooted at a given starting file.
|
abstract Iterable |
FileSystem.getRootDirectories()
Returns an object to iterate over the paths of the root directories.
|
Iterator |
Path.iterator()
Returns an iterator over the name elements of this path.
|
static Stream |
Files.list(Path
Return a lazily populated
Stream, the elements of which are the entries in the directory.
|
static DirectoryStream |
Files.newDirectoryStream(Path
Opens a directory, returning a
DirectoryStream to iterate over all entries in the directory.
|
static DirectoryStream |
Files.newDirectoryStream(Path
Opens a directory, returning a
DirectoryStream to iterate over the entries in the directory.
|
static DirectoryStream |
Files.newDirectoryStream(Path
Opens a directory, returning a
DirectoryStream to iterate over the entries in the directory.
|
static Stream |
Files.walk(Path
Return a
Stream that is lazily populated with
Path by walking the file tree rooted at a given starting file.
|
static Stream |
Files.walk(Path
Return a
Stream that is lazily populated with
Path by walking the file tree rooted at a given starting file.
|
| Modifier and Type | Method and Description |
|---|---|
int |
Path.compareTo(Path
Compares two abstract paths lexicographically.
|
static long |
Files.copy(InputStream
Copies all bytes from an input stream to a file.
|
static long |
Files.copy(Path
Copies all bytes from a file to an output stream.
|
static Path |
Files.copy(Path
Copy a file to a target file.
|
static Path |
Files.createDirectories(Path
Creates a directory by creating all nonexistent parent directories first.
|
static Path |
Files.createDirectory(Path
Creates a new directory.
|
static Path |
Files.createFile(Path
Creates a new and empty file, failing if the file already exists.
|
static Path |
Files.createLink(Path
Creates a new link (directory entry) for an existing file
(optional operation).
|
static Path |
Files.createSymbolicLink(Path
Creates a symbolic link to a target
(optional operation).
|
static Path |
Files.createTempDirectory(Path
Creates a new directory in the specified directory, using the given prefix to generate its name.
|
static Path |
Files.createTempFile(Path
Creates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name.
|
static void |
Files.delete(Path
Deletes a file.
|
static boolean |
Files.deleteIfExists(Path
Deletes a file if it exists.
|
boolean |
Path.endsWith(Path
Tests if this path ends with the given path.
|
static boolean |
Files.exists(Path
Tests whether a file exists.
|
static Stream |
Files.find(Path
Return a
Stream that is lazily populated with
Path by searching for files in a file tree rooted at a given starting file.
|
static Object |
Files.getAttribute(Path
Reads the value of a file attribute.
|
static <V extends FileAttributeView |
Files.getFileAttributeView(Path
Returns a file attribute view of a given type.
|
static FileStore |
Files.getFileStore(Path
Returns the
FileStore representing the file store where a file is located.
|
static FileTime |
Files.getLastModifiedTime(Path
Returns a file's last modified time.
|
static UserPrincipal |
Files.getOwner(Path
Returns the owner of a file.
|
static Set |
Files.getPosixFilePermissions(Path
Returns a file's POSIX file permissions.
|
static boolean |
Files.isDirectory(Path
Tests whether a file is a directory.
|
static boolean |
Files.isExecutable(Path
Tests whether a file is executable.
|
static boolean |
Files.isHidden(Path
Tells whether or not a file is considered
hidden.
|
static boolean |
Files.isReadable(Path
Tests whether a file is readable.
|
static boolean |
Files.isRegularFile(Path
Tests whether a file is a regular file with opaque content.
|
static boolean |
Files.isSameFile(Path
Tests if two paths locate the same file.
|
static boolean |
Files.isSymbolicLink(Path
Tests whether a file is a symbolic link.
|
static boolean |
Files.isWritable(Path
Tests whether a file is writable.
|
static Stream |
Files.lines(Path
Read all lines from a file as a
Stream.
|
static Stream |
Files.lines(Path
Read all lines from a file as a
Stream.
|
static Stream |
Files.list(Path
Return a lazily populated
Stream, the elements of which are the entries in the directory.
|
boolean |
PathMatcher.matches(Path
Tells if given path matches this matcher's pattern.
|
static Path |
Files.move(Path
Move or rename a file to a target file.
|
static BufferedReader |
Files.newBufferedReader(Path
Opens a file for reading, returning a
BufferedReader to read text from the file in an efficient manner.
|
static BufferedReader |
Files.newBufferedReader(Path
Opens a file for reading, returning a
BufferedReader that may be used to read text from the file in an efficient manner.
|
static BufferedWriter |
Files.newBufferedWriter(Path
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 BufferedWriter |
Files.newBufferedWriter(Path
Opens or creates a file for writing, returning a
BufferedWriter to write text to the file in an efficient manner.
|
static SeekableByteChannel |
Files.newByteChannel(Path
Opens or creates a file, returning a seekable byte channel to access the file.
|
static SeekableByteChannel |
Files.newByteChannel(Path
Opens or creates a file, returning a seekable byte channel to access the file.
|
static DirectoryStream |
Files.newDirectoryStream(Path
Opens a directory, returning a
DirectoryStream to iterate over all entries in the directory.
|
static DirectoryStream |
Files.newDirectoryStream(Path
Opens a directory, returning a
DirectoryStream to iterate over the entries in the directory.
|
static DirectoryStream |
Files.newDirectoryStream(Path
Opens a directory, returning a
DirectoryStream to iterate over the entries in the directory.
|
static FileSystem |
FileSystems.newFileSystem(Path
Constructs a new
FileSystem to access the contents of a file as a file system.
|
static InputStream |
Files.newInputStream(Path
Opens a file, returning an input stream to read from the file.
|
static OutputStream |
Files.newOutputStream(Path
Opens or creates a file, returning an output stream that may be used to write bytes to the file.
|
static boolean |
Files.notExists(Path
Tests whether the file located by this path does not exist.
|
static String |
Files.probeContentType(Path
Probes the content type of a file.
|
static byte[] |
Files.readAllBytes(Path
Reads all the bytes from a file.
|
static List |
Files.readAllLines(Path
Read all lines from a file.
|
static List |
Files.readAllLines(Path
Read all lines from a file.
|
static <A extends BasicFileAttributes |
Files.readAttributes(Path
Reads a file's attributes as a bulk operation.
|
static Map |
Files.readAttributes(Path
Reads a set of file attributes as a bulk operation.
|
static Path |
Files.readSymbolicLink(Path
Reads the target of a symbolic link
(optional operation).
|
Path |
Path.relativize(Path
Constructs a relative path between this path and a given path.
|
Path |
Path.resolve(Path
Resolve the given path against this path.
|
Path |
Path.resolveSibling(Path
Resolves the given path against this path's
parent path.
|
static Path |
Files.setAttribute(Path
Sets the value of a file attribute.
|
static Path |
Files.setLastModifiedTime(Path
Updates a file's last modified time attribute.
|
static Path |
Files.setOwner(Path
Updates the file owner.
|
static Path |
Files.setPosixFilePermissions(Path
Sets a file's POSIX permissions.
|
static long |
Files.size(Path
Returns the size of a file (in bytes).
|
boolean |
Path.startsWith(Path
Tests if this path starts with the given path.
|
static Stream |
Files.walk(Path
Return a
Stream that is lazily populated with
Path by walking the file tree rooted at a given starting file.
|
static Stream |
Files.walk(Path
Return a
Stream that is lazily populated with
Path by walking the file tree rooted at a given starting file.
|
static Path |
Files.walkFileTree(Path
Walks a file tree.
|
static Path |
Files.walkFileTree(Path
Walks a file tree.
|
static Path |
Files.write(Path
Writes bytes to a file.
|
static Path |
Files.write(Path
Write lines of text to a file.
|
static Path |
Files.write(Path
Write lines of text to a file.
|
| Modifier and Type | Method and Description |
|---|---|
static Stream |
Files.find(Path
Return a
Stream that is lazily populated with
Path by searching for files in a file tree rooted at a given starting file.
|
static DirectoryStream |
Files.newDirectoryStream(Path
Opens a directory, returning a
DirectoryStream to iterate over the entries in the directory.
|
static Path |
Files.walkFileTree(Path
Walks a file tree.
|
static Path |
Files.walkFileTree(Path
Walks a file tree.
|
| Modifier and Type | Method and Description |
|---|---|
abstract Path |
FileSystemProvider.getPath(URI
Return a
Path object by converting the given
URI.
|
Path |
FileSystemProvider.readSymbolicLink(Path
Reads the target of a symbolic link.
|
| Modifier and Type | Method and Description |
|---|---|
abstract DirectoryStream |
FileSystemProvider.newDirectoryStream(Path
Opens a directory, returning a
DirectoryStream to iterate over the entries in the directory.
|
| Modifier and Type | Method and Description |
|---|---|
abstract void |
FileSystemProvider.checkAccess(Path
Checks the existence, and optionally the accessibility, of a file.
|
abstract void |
FileSystemProvider.copy(Path
Copy a file to a target file.
|
abstract void |
FileSystemProvider.createDirectory(Path
Creates a new directory.
|
void |
FileSystemProvider.createLink(Path
Creates a new link (directory entry) for an existing file.
|
void |
FileSystemProvider.createSymbolicLink(Path
Creates a symbolic link to a target.
|
abstract void |
FileSystemProvider.delete(Path
Deletes a file.
|
boolean |
FileSystemProvider.deleteIfExists(Path
Deletes a file if it exists.
|
abstract <V extends FileAttributeView |
FileSystemProvider.getFileAttributeView(Path
Returns a file attribute view of a given type.
|
abstract FileStore |
FileSystemProvider.getFileStore(Path
Returns the
FileStore representing the file store where a file is located.
|
abstract boolean |
FileSystemProvider.isHidden(Path
Tells whether or not a file is considered
hidden.
|
abstract boolean |
FileSystemProvider.isSameFile(Path
Tests if two paths locate the same file.
|
abstract void |
FileSystemProvider.move(Path
Move or rename a file to a target file.
|
AsynchronousFileChannel |
FileSystemProvider.newAsynchronousFileChannel(Path
Opens or creates a file for reading and/or writing, returning an asynchronous file channel to access the file.
|
abstract SeekableByteChannel |
FileSystemProvider.newByteChannel(Path
Opens or creates a file, returning a seekable byte channel to access the file.
|
abstract DirectoryStream |
FileSystemProvider.newDirectoryStream(Path
Opens a directory, returning a
DirectoryStream to iterate over the entries in the directory.
|
FileChannel |
FileSystemProvider.newFileChannel(Path
Opens or creates a file for reading and/or writing, returning a file channel to access the file.
|
FileSystem |
FileSystemProvider.newFileSystem(Path
Constructs a new
FileSystem to access the contents of a file as a file system.
|
InputStream |
FileSystemProvider.newInputStream(Path
Opens a file, returning an input stream to read from the file.
|
OutputStream |
FileSystemProvider.newOutputStream(Path
Opens or creates a file, returning an output stream that may be used to write bytes to the file.
|
abstract String |
FileTypeDetector.probeContentType(Path
Probes the given file to guess its content type.
|
abstract <A extends BasicFileAttributes |
FileSystemProvider.readAttributes(Path
Reads a file's attributes as a bulk operation.
|
abstract Map |
FileSystemProvider.readAttributes(Path
Reads a set of file attributes as a bulk operation.
|
Path |
FileSystemProvider.readSymbolicLink(Path
Reads the target of a symbolic link.
|
abstract void |
FileSystemProvider.setAttribute(Path
Sets the value of a file attribute.
|
| Modifier and Type | Method and Description |
|---|---|
abstract DirectoryStream |
FileSystemProvider.newDirectoryStream(Path
Opens a directory, returning a
DirectoryStream to iterate over the entries in the directory.
|
| Constructor and Description | |
|---|---|
Scanner(Path
Constructs a new
Scanner that produces values scanned from the specified file.
|
|
Scanner(Path
Constructs a new
Scanner that produces values scanned from the specified file.
|