Example usage for Java java.nio.file Files fields, constructors, methods, implement or subclass
The text is from its open source code.
long | copy(Path source, OutputStream out) Copies all bytes from a file to an output stream. |
Path | copy(Path source, Path target, CopyOption... options) Copy a file to a target file. |
long | copy(InputStream in, Path target, CopyOption... options) Copies all bytes from an input stream to a file. |
Path | createDirectories(Path dir, FileAttribute>... attrs) Creates a directory by creating all nonexistent parent directories first. |
Path | createDirectory(Path dir, FileAttribute>... attrs) Creates a new directory. |
Path | createFile(Path path, FileAttribute>... attrs) Creates a new and empty file, failing if the file already exists. |
Path | createLink(Path link, Path existing) Creates a new link (directory entry) for an existing file (optional operation). |
Path | createTempDirectory(String prefix, FileAttribute>... attrs) Creates a new directory in the default temporary-file directory, using the given prefix to generate its name. |
Path | createTempDirectory(Path dir, String prefix, FileAttribute>... attrs) Creates a new directory in the specified directory, using the given prefix to generate its name. |
Path | createTempFile(String prefix, String suffix, FileAttribute>... attrs) Creates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name. |
Path | createTempFile(Path dir, String prefix, String suffix, FileAttribute>... attrs) Creates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name. |
void | delete(Path path) Deletes a file. |
boolean | deleteIfExists(Path path) Deletes a file if it exists. |
boolean | exists(Path path, LinkOption... options) Tests whether a file exists. |
Stream | find(Path start, int maxDepth, BiPredicate Return a Stream that is lazily populated with Path by searching for files in a file tree rooted at a given starting file. |
Object | getAttribute(Path path, String attribute, LinkOption... options) Reads the value of a file attribute. |
V | getFileAttributeView(Path path, Class Returns a file attribute view of a given type. |
FileStore | getFileStore(Path path) Returns the FileStore representing the file store where a file is located. |
FileTime | getLastModifiedTime(Path path, LinkOption... options) Returns a file's last modified time. |
UserPrincipal | getOwner(Path path, LinkOption... options) Returns the owner of a file. |
Set | getPosixFilePermissions(Path path, LinkOption... options) Returns a file's POSIX file permissions. |
boolean | isDirectory(Path path, LinkOption... options) Tests whether a file is a directory. |
boolean | isExecutable(Path path) Tests whether a file is executable. |
boolean | isHidden(Path path) Tells whether or not a file is considered hidden. |
boolean | isReadable(Path path) Tests whether a file is readable. |
boolean | isRegularFile(Path path, LinkOption... options) Tests whether a file is a regular file with opaque content. |
boolean | isSameFile(Path path, Path path2) Tests if two paths locate the same file. |
boolean | isSymbolicLink(Path path) Tests whether a file is a symbolic link. |
boolean | isWritable(Path path) Tests whether a file is writable. |
Stream | lines(Path path) Read all lines from a file as a Stream . |
Stream | lines(Path path, Charset cs) Read all lines from a file as a Stream . |
Stream | list(Path dir) Return a lazily populated Stream , the elements of which are the entries in the directory. |
Path | move(Path source, Path target, CopyOption... options) Move or rename a file to a target file. |
BufferedReader | newBufferedReader(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. |
BufferedReader | newBufferedReader(Path path) Opens a file for reading, returning a BufferedReader to read text from the file in an efficient manner. |
BufferedWriter | newBufferedWriter(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. |
BufferedWriter | newBufferedWriter(Path path, OpenOption... options) Opens or creates a file for writing, returning a BufferedWriter to write text to the file in an efficient manner. |
SeekableByteChannel | newByteChannel(Path path, OpenOption... options) Opens or creates a file, returning a seekable byte channel to access the file. |
SeekableByteChannel | newByteChannel(Path path, Set extends OpenOption> options, FileAttribute>... attrs) Opens or creates a file, returning a seekable byte channel to access the file. |
DirectoryStream | newDirectoryStream(Path dir, String glob) Opens a directory, returning a DirectoryStream to iterate over the entries in the directory. |
DirectoryStream | newDirectoryStream(Path dir, DirectoryStream.Filter super Path> filter) Opens a directory, returning a DirectoryStream to iterate over the entries in the directory. |
DirectoryStream | newDirectoryStream(Path dir) Opens a directory, returning a DirectoryStream to iterate over all entries in the directory. |
InputStream | newInputStream(Path path, OpenOption... options) Opens a file, returning an input stream to read from the file. |
OutputStream | newOutputStream(Path path, OpenOption... options) Opens or creates a file, returning an output stream that may be used to write bytes to the file. |
boolean | notExists(Path path, LinkOption... options) Tests whether the file located by this path does not exist. |
String | probeContentType(Path path) Probes the content type of a file. |
byte[] | readAllBytes(Path path) Reads all the bytes from a file. |
List | readAllLines(Path path, Charset cs) Read all lines from a file. |
List | readAllLines(Path path) Read all lines from a file. |
A | readAttributes(Path path, Class type, LinkOption... options) Reads a file's attributes as a bulk operation. |
Map | readAttributes(Path path, String attributes, LinkOption... options) Reads a set of file attributes as a bulk operation. |
String | readString(Path path) Reads all content from a file into a string, decoding from bytes to characters using the StandardCharsets#UTF_8 UTF-8 Charset charset . |
Path | readSymbolicLink(Path link) Reads the target of a symbolic link (optional operation). |
Path | setAttribute(Path path, String attribute, Object value, LinkOption... options) Sets the value of a file attribute. |
Path | setLastModifiedTime(Path path, FileTime time) Updates a file's last modified time attribute. |
Path | setOwner(Path path, UserPrincipal owner) Updates the file owner. |
Path | setPosixFilePermissions(Path path, Set Sets a file's POSIX permissions. |
long | size(Path path) Returns the size of a file (in bytes). |
Stream | walk(Path start, FileVisitOption... options) Return a Stream that is lazily populated with Path by walking the file tree rooted at a given starting file. |
Stream | walk(Path start, int maxDepth, FileVisitOption... options) Return a Stream that is lazily populated with Path by walking the file tree rooted at a given starting file. |
Path | walkFileTree(Path start, FileVisitor super Path> visitor) Walks a file tree. |
Path | walkFileTree(Path start, Set Walks a file tree. |
Path | write(Path path, byte[] bytes, OpenOption... options) Writes bytes to a file. |
Path | write(Path path, Iterable extends CharSequence> lines, OpenOption... options) Write lines of text to a file. |
Path | write(Path path, Iterable extends CharSequence> lines, Charset cs, OpenOption... options) Write lines of text to a file. |