The Power of Java 7 NIO.2

本文详细介绍了Java NIO在JDK7之前的版本及Java SE7中提供的文件系统访问方式,包括使用java.nio.file.FileSystems类获取文件系统实例、默认方法getDefault()、通过URI获取特定文件系统的方法getFileSystem(),以及Path类支持的操作如元数据文件属性查询、符号链接与硬链接创建等。同时,文中还提到了文件和目录操作、文件访问结果常量、监视服务API和强大的随机访问文件功能。

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

 

  

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值