The Power of Java 7 NIO.2

来源:互联网 发布:马勒交响曲知乎 编辑:程序博客网 时间:2024/04/29 21:58

version1 NIO before the JDK 7

version 2 NIO delivered in Java SE 7

Working with the new Path Class

The file system can be accessed through the java.nio.file.FileSystems final calss which is used to get an instance of the java.nio.file.FileSystems we need

FileSystems contains the following two important methods as well as a set of newFileSystem() methods, for constructing new file systems:

getDefault()

This is a static method that returns a fule system from the set of available file system to the JVM

getFileSystem(URI uri)

This is a static method that returns file system from the set of available file system provides taht match the gevien URI schema

The Path calss supports two types of operations:

Syntactic operations

Logical mapulations done in memory

&Operations over files

 

metadata File attributes

if you have questions abount a file or a directory, such whether is is hidden;

NIO.2 groups the attributes into views, each of which maps to a particular file system implementation

java.nio.file.attribute

Symbolic and Hard links

java.nio.file.Files-->createSystembolicLink(), isSymbolicLink(), and readSymbolicLink()

hardLink should be within the same system.

Files and Directories

NIO.2 comes with a set of brand new methods to accomplish these tasks. most of which are found in the java.nio.file.Files calss

 

The FileVistor interface

for(FileVisitResult constant: FileVisitResult.values())

system.out.println(constant)

class search implement fileVistor

Monitoring VIA Watch Service API

New powerful Random Access Files

 

  

 

原创粉丝点击