Java java.nio.file Files fields, constructors, methods, implement or subclass

Example usage for Java java.nio.file Files fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for java.nio.file Files.

The text is from its open source code.

Method

longcopy(Path source, OutputStream out)
Copies all bytes from a file to an output stream.
Pathcopy(Path source, Path target, CopyOption... options)
Copy a file to a target file.
longcopy(InputStream in, Path target, CopyOption... options)
Copies all bytes from an input stream to a file.
PathcreateDirectories(Path dir, FileAttribute... attrs)
Creates a directory by creating all nonexistent parent directories first.
PathcreateDirectory(Path dir, FileAttribute... attrs)
Creates a new directory.
PathcreateFile(Path path, FileAttribute... attrs)
Creates a new and empty file, failing if the file already exists.
PathcreateLink(Path link, Path existing)
Creates a new link (directory entry) for an existing file (optional operation).
PathcreateTempDirectory(String prefix, FileAttribute... attrs)
Creates a new directory in the default temporary-file directory, using the given prefix to generate its name.
PathcreateTempDirectory(Path dir, String prefix, FileAttribute... attrs)
Creates a new directory in the specified directory, using the given prefix to generate its name.
PathcreateTempFile(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.
PathcreateTempFile(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.
voiddelete(Path path)
Deletes a file.
booleandeleteIfExists(Path path)
Deletes a file if it exists.
booleanexists(Path path, LinkOption... options)
Tests whether a file exists.
Streamfind(Path start, int maxDepth, BiPredicate matcher, FileVisitOption... options)
Return a Stream that is lazily populated with Path by searching for files in a file tree rooted at a given starting file.
ObjectgetAttribute(Path path, String attribute, LinkOption... options)
Reads the value of a file attribute.
VgetFileAttributeView(Path path, Class type, LinkOption... options)
Returns a file attribute view of a given type.
FileStoregetFileStore(Path path)
Returns the FileStore representing the file store where a file is located.
FileTimegetLastModifiedTime(Path path, LinkOption... options)
Returns a file's last modified time.
UserPrincipalgetOwner(Path path, LinkOption... options)
Returns the owner of a file.
SetgetPosixFilePermissions(Path path, LinkOption... options)
Returns a file's POSIX file permissions.
booleanisDirectory(Path path, LinkOption... options)
Tests whether a file is a directory.
booleanisExecutable(Path path)
Tests whether a file is executable.
booleanisHidden(Path path)
Tells whether or not a file is considered hidden.
booleanisReadable(Path path)
Tests whether a file is readable.
booleanisRegularFile(Path path, LinkOption... options)
Tests whether a file is a regular file with opaque content.
booleanisSameFile(Path path, Path path2)
Tests if two paths locate the same file.
booleanisSymbolicLink(Path path)
Tests whether a file is a symbolic link.
booleanisWritable(Path path)
Tests whether a file is writable.
Streamlines(Path path)
Read all lines from a file as a Stream .
Streamlines(Path path, Charset cs)
Read all lines from a file as a Stream .
Streamlist(Path dir)
Return a lazily populated Stream , the elements of which are the entries in the directory.
Pathmove(Path source, Path target, CopyOption... options)
Move or rename a file to a target file.
BufferedReadernewBufferedReader(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.
BufferedReadernewBufferedReader(Path path)
Opens a file for reading, returning a BufferedReader to read text from the file in an efficient manner.
BufferedWriternewBufferedWriter(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.
BufferedWriternewBufferedWriter(Path path, OpenOption... options)
Opens or creates a file for writing, returning a BufferedWriter to write text to the file in an efficient manner.
SeekableByteChannelnewByteChannel(Path path, OpenOption... options)
Opens or creates a file, returning a seekable byte channel to access the file.
SeekableByteChannelnewByteChannel(Path path, Set options, FileAttribute... attrs)
Opens or creates a file, returning a seekable byte channel to access the file.
DirectoryStreamnewDirectoryStream(Path dir, String glob)
Opens a directory, returning a DirectoryStream to iterate over the entries in the directory.
DirectoryStreamnewDirectoryStream(Path dir, DirectoryStream.Filter filter)
Opens a directory, returning a DirectoryStream to iterate over the entries in the directory.
DirectoryStreamnewDirectoryStream(Path dir)
Opens a directory, returning a DirectoryStream to iterate over all entries in the directory.
InputStreamnewInputStream(Path path, OpenOption... options)
Opens a file, returning an input stream to read from the file.
OutputStreamnewOutputStream(Path path, OpenOption... options)
Opens or creates a file, returning an output stream that may be used to write bytes to the file.
booleannotExists(Path path, LinkOption... options)
Tests whether the file located by this path does not exist.
StringprobeContentType(Path path)
Probes the content type of a file.
byte[]readAllBytes(Path path)
Reads all the bytes from a file.
ListreadAllLines(Path path, Charset cs)
Read all lines from a file.
ListreadAllLines(Path path)
Read all lines from a file.
AreadAttributes(Path path, Class type, LinkOption... options)
Reads a file's attributes as a bulk operation.
MapreadAttributes(Path path, String attributes, LinkOption... options)
Reads a set of file attributes as a bulk operation.
StringreadString(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 .
PathreadSymbolicLink(Path link)
Reads the target of a symbolic link (optional operation).
PathsetAttribute(Path path, String attribute, Object value, LinkOption... options)
Sets the value of a file attribute.
PathsetLastModifiedTime(Path path, FileTime time)
Updates a file's last modified time attribute.
PathsetOwner(Path path, UserPrincipal owner)
Updates the file owner.
PathsetPosixFilePermissions(Path path, Set perms)
Sets a file's POSIX permissions.
longsize(Path path)
Returns the size of a file (in bytes).
Streamwalk(Path start, FileVisitOption... options)
Return a Stream that is lazily populated with Path by walking the file tree rooted at a given starting file.
Streamwalk(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.
PathwalkFileTree(Path start, FileVisitor visitor)
Walks a file tree.
PathwalkFileTree(Path start, Set options, int maxDepth, FileVisitor visitor)
Walks a file tree.
Pathwrite(Path path, byte[] bytes, OpenOption... options)
Writes bytes to a file.
Pathwrite(Path path, Iterable lines, OpenOption... options)
Write lines of text to a file.
Pathwrite(Path path, Iterable lines, Charset cs, OpenOption... options)
Write lines of text to a file.