First, the basic knowledge
Java provides another set of buffer-oriented, channel-based I/O systems that represent connections that open to I/O devices.
The path interface encapsulates the file path and provides a number of ways to manipulate the path.
The files class provides a static method for file operations, using path to specify the path.
Second, the basic operation
Read and write files through channels.
View Code
By mapping files to buffer read-write files, buffers automatically read files or write to files.
View Code
Copy the file.
View Code
Stream-based usage.
View Code
Iii. path-and file-system-based operations
Get file-related information.
View Code
Lists the contents of the catalog.
View Code
Filter the contents of the catalog.
View Code
Lists the directory tree. The implementation of the Filevisitor interface determines how the directory tree is traversed, and filevisitor-defined methods return Filevisitresult enumeration objects.
- CONTINUE: Continue traversing the directory.
- TERMINATE: Stop traversing the directory.
- Skip_sublings: Skips the current directory and its sibling directory.
- Skip_subtree: Skips the current directory.
View Code
Java notes: Non-blocking I/O